From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B1E92A04F6; Mon, 6 Jan 2020 20:18:49 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 299401D6ED; Mon, 6 Jan 2020 20:18:49 +0100 (CET) Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) by dpdk.org (Postfix) with ESMTP id 81BBA1D6E7 for ; Mon, 6 Jan 2020 20:18:47 +0100 (CET) Received: by mail-pj1-f68.google.com with SMTP id t101so8158447pjb.4 for ; Mon, 06 Jan 2020 11:18:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jSzDJgEq3YbbKoBA1ciEtK9PRoZzGlvORhXB16vdCXM=; b=orhBa4bvrjL5CEWScF9d09gcaxqG6OqJp3hj6A4pfco//NQ0a7G0zUoMMFtZHiZmhM bAlbqtkX8+4PNJ0n86qGWOl/Qr33VISmyzUHHbRZ8Hxev9/1fz3oDymzklCyyHb5RABv IqCAV/wQdPfK4kGFuwe/kmueJUXvBTFZsfNydoPGxmvYtaGWcci3rr/yH69ztMUClYFv dHkRJalc3KoAQ0y9IPlgzPyA1ZIhm27L9G39mHTY5OGTFk0qSJvrfFUUtzGoPdpPHfSL fZoi7oy18ZRGyhQNW6UKnJiulTN96i8H2gEA7TEKuzSG+crjnzxyCJCAspIu5/2soim/ r5bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jSzDJgEq3YbbKoBA1ciEtK9PRoZzGlvORhXB16vdCXM=; b=QWw0L8czgQUAftihF16LFdeXSXNwdJMMC7kBcyxAxtJfzfmo2xDgiv+2er58mZ3RL4 TZC8kq3F+Wc0do9e5F1+Cj3bf6rnS9OhDWV/WadZj7ctkoSHrCyMcZ/tO3Fo78PVtFUZ r5hrW6/lEqpwDmfSZhsrLrDN1Hg29O5vweHQmHWq8jJeW4HKuU4kSB0GOwDA4o8qMYmv 3n3OmwgPagz3va0fRWMatZBNq8KcL8MBRxu4nZbmBz9WrpBfVC14WU9ifKoxPRW88CvA 7bvWPYJQqMguEnt9UuxIDXT30KnowOhCHRbhz7TGk/HaUp+wvxA4eQuYcHlG6nOEjjd/ 7Jzg== X-Gm-Message-State: APjAAAVjGruVImyDi8DaJl66fF+TgbqY/fLISSYE6zWJgrsrIn5AI4N9 ecS6m7LWokjRMdf2OwMeo9jfvjX0dUA= X-Google-Smtp-Source: APXvYqzVcTnIjmH0JrOh7OrUBCqsCfNpSKOgLsV7x3updQDBcC+I2Ny6YoX8KrA8YlIwdqMdKHl0Ow== X-Received: by 2002:a17:90a:ec0f:: with SMTP id l15mr43136172pjy.39.1578338326151; Mon, 06 Jan 2020 11:18:46 -0800 (PST) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id v5sm6175226pfn.122.2020.01.06.11.18.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 11:18:45 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , jianfeng.tan@intel.com, stable@dpdk.org Date: Mon, 6 Jan 2020 11:18:37 -0800 Message-Id: <20200106191837.29076-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] net/virtio_user: do not close invalid file descriptor X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Valgrind complains that virtio_user is calling close(-1). Fix this by adding check in virtio that is similar to existing code. Fixes: 37a7eb2ae816 ("net/virtio-user: add device emulation layer") Cc: jianfeng.tan@intel.com Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger --- drivers/net/virtio/virtio_user/virtio_user_dev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index ea016e85d8af..ffbaa75b7e83 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -537,7 +537,8 @@ virtio_user_dev_uninit(struct virtio_user_dev *dev) close(dev->kickfds[i]); } - close(dev->vhostfd); + if (dev->vhostfd >= 0) + close(dev->vhostfd); if (dev->is_server && dev->listenfd >= 0) { close(dev->listenfd); -- 2.20.1