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 3917AA04F6 for ; Mon, 6 Jan 2020 20:18:48 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E4A421D6EA; Mon, 6 Jan 2020 20:18:47 +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 2DFD21D6E7 for ; Mon, 6 Jan 2020 20:18:47 +0100 (CET) Received: by mail-pj1-f68.google.com with SMTP id l35so8157056pje.3 for ; Mon, 06 Jan 2020 11:18:46 -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=csFBOrUo3ewdgOAzyh06DZvbq1GXCM0h4gKd+gLMDdulZzcmsSpLvknLdKt6Tu9Oj/ phKhDuiD+lPG2NkLnDyrL6c+6IK5IbHcA3iFnzM3wMPKXqi6x+0xxJfzrrQ+q9a0OYWj Cb1Fz8FslQ9YSAVlVIuG558MQpEE+Z5PC4O1BN41bauWCacKwmCteMSXGAuRETyu+F3B gOPmill7Uxj88gKawu67+0TOcpZYOFIvM4tDK4bSSqW2wumPf/9JvdxRNI6NOI+8BcLQ A0QNAphqD92clLsFwnzJLIQbxHFDpQXi4VlcBxChGFTPhd14ol6utRdijgQz5qMTwfnT rEpg== X-Gm-Message-State: APjAAAWeHcL/+WbfdcUbDU898/ktgKGOPs2HiLD861BUDcaNv3KZeA40 23bUPyt0kqHKVbdbkKt0YSzfIw== 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-stable] [PATCH] net/virtio_user: do not close invalid file descriptor X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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