From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by dpdk.org (Postfix) with ESMTP id B0A5B2C52 for ; Tue, 6 Nov 2018 20:30:11 +0100 (CET) Received: by mail-pg1-f195.google.com with SMTP id 32-v6so6259745pgu.2 for ; Tue, 06 Nov 2018 11:30:11 -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:in-reply-to:references; bh=SnVbfOOs81D3X9Pr0bY0M2EFZpVp0/4RNXCCiEDZPVM=; b=l+p3OYeTo/50tbqdSa12SZBR7J35JixslQQVS2AO5wIf7laxXVXTnbyqNyP2Ea1MoT l0qDXLQ8+8+tAKZsAHKoEND6srvzR48mu3FVSTorOE/rL1gB++OYj3e4lTO925qhqrz9 XS+HArtMcZvMiVfoZx/XLfcSayvFtAA6vIybtBC4g5J1XphPt/QWRSwxfhj8UT36tXoX 6GpVeejQL/yodFUyrnCmNXKC8ybukReF8oq3yDAueNCJ8wEb7H9dRv+EzgX1fZqXg/YX R2UcVZqkSPiACaCLY8YOsr5eSGdY5ozdzBu0axhKZBm1GJ4eWc41EjvXRLTjLzQMI/QW PZhg== 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:in-reply-to :references; bh=SnVbfOOs81D3X9Pr0bY0M2EFZpVp0/4RNXCCiEDZPVM=; b=o7/z0SAn15dPP6SMHXd0gz2+XwgnzCx5uYD5rYSoSXcWNnmKFYnHOS8zI+cG3gCVVm 440CriipprKiB+q67SCG27ZJesLTlJkM+TgoO9kQVPhFEljfUSeaWpYAzwlpj9ZhslOk enL60o+Xo/jK2WBGvjFjmCGcZgn3I6OHu6DdFuCEu0NRL/U9DtIowHVevWD/WPRGjFge YnuxcRIeu5orpHLQ37LpGjtnEihj21AjDM5YRGi3Lw32BiKnX835+dC4KDV5ISiT+1eu w2ECSib9f4rG4TEORQZOny47cyIVZ+AiRryhwSs64KkxBOgSMe+FwItXlBUm7VIpCkiN SaoA== X-Gm-Message-State: AGRZ1gKyPdWu7M+RdbF7c4DlL0DtK4k+36tth4XYytgQU3U/sRKrPDY3 9FxFvLJ5xl/afjx12kEZ6Cn+TojES0s= X-Google-Smtp-Source: AJdET5dBG10M/6iVNGOTuYzpf3EzP/bzt+fzroxJP5Ddcd7fvi2tzM3LCBH9DAbNVCqW1fxrAF6JEA== X-Received: by 2002:aa7:83c2:: with SMTP id j2-v6mr27501216pfn.91.1541532610275; Tue, 06 Nov 2018 11:30:10 -0800 (PST) Received: from localhost.localdomain ([167.220.105.115]) by smtp.gmail.com with ESMTPSA id a18sm9638633pgj.30.2018.11.06.11.30.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 11:30:09 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 6 Nov 2018 11:30:04 -0800 Message-Id: <20181106193005.5383-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181106193005.5383-1-stephen@networkplumber.org> References: <20181106193005.5383-1-stephen@networkplumber.org> Subject: [dpdk-dev] [PATCH 3/4] net/tap: fix file descriptor leak on error 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: , X-List-Received-Date: Tue, 06 Nov 2018 19:30:12 -0000 If netlink socket setup fails the file descriptor was leaked. Coverity issue: 257040 Fixes: 7c25284e30c2 ("net/tap: add netlink back-end for flow API") Signed-off-by: Stephen Hemminger --- drivers/net/tap/tap_netlink.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/tap/tap_netlink.c b/drivers/net/tap/tap_netlink.c index 6cb510092218..14bbbec754f6 100644 --- a/drivers/net/tap/tap_netlink.c +++ b/drivers/net/tap/tap_netlink.c @@ -51,14 +51,17 @@ tap_nl_init(uint32_t nl_groups) } if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &sndbuf_size, sizeof(int))) { TAP_LOG(ERR, "Unable to set socket buffer send size"); + close(fd); return -1; } if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &rcvbuf_size, sizeof(int))) { TAP_LOG(ERR, "Unable to set socket buffer receive size"); + close(fd); return -1; } if (bind(fd, (struct sockaddr *)&local, sizeof(local)) < 0) { TAP_LOG(ERR, "Unable to bind to the netlink socket"); + close(fd); return -1; } return fd; -- 2.17.1