Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3551814imm; Tue, 17 Jul 2018 06:44:45 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe3eRyQ0w4JS6iCeGO02QnEvh1x/GTEBkwlFN1znijjnOXgLzbHXTqcMBRitCnu16Tzbtcn X-Received: by 2002:a17:902:988c:: with SMTP id s12-v6mr1699664plp.199.1531835085344; Tue, 17 Jul 2018 06:44:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531835085; cv=none; d=google.com; s=arc-20160816; b=yP0hf+lFYjiqsjC4j26+9vFFIPQoOltDDbCse/MG5muXDAasAmktCeY04Sf2ihm02V MnVktz70VsqNdj5mqAWF6ViR2S2QmBWk1nJhSj0Lca0oz/fXSPIDFSWDxIQs/5SEmYEs sX2rgRzTJrS2eDpF9R1XWhxrE9t84R+vYKZWCRO/Xyg8iYIfrFuvcjKaBU6EUjELjnvR eCYKjQq0vHzyE6VEb3lGV7AKnI3boP8iHZTai7q72hM/Z/ANfiwpPCRGfjaSYCeo7PUL 72HLfsqjxqOURPdk3u504hE3FveXHWTpgJg1iLTO7SXecp8jw3YRcM2gJ4+biIzs5nqb 8wyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date :arc-authentication-results; bh=pth7ISYwFbGTmTGJpx7a3B+dIdBSgf3Q6xTmPFTUZFU=; b=h0posGNU0S2++NWH89IPJ7HPtumxZ0H1Db3EpH4C94su/9X82x+XSg+nUpyyuzD35l UJKrxRj68O/U1GZ9CQ2G+IIdDRz1ppyuHgSXrjiR4mNdfUBi7LOjro6HYgwugUAgG478 YcCA6e4DNDMFzuSQKDdNblVt40jRoWKgH05fSsh/w1nDbGufr9RA32Q9VOhHLZ3Q7TCH v4VO7v+kavvGx+tTjArthoE5IIjlWB0mP8WGMdSF5LKM31rurCFR6RBrc3QlzXeV+WJE XvAPtwdd2G4Kb5YI1FFqhjoah6iV0fvQFY83xYDfM0h8Ov8cB/O0BnD8NhVjj8AwhBgI vTuQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s2-v6si1073723pfs.2.2018.07.17.06.44.30; Tue, 17 Jul 2018 06:44:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731821AbeGQOQ0 (ORCPT + 99 others); Tue, 17 Jul 2018 10:16:26 -0400 Received: from gateway34.websitewelcome.com ([192.185.149.13]:18753 "EHLO gateway34.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731603AbeGQOQZ (ORCPT ); Tue, 17 Jul 2018 10:16:25 -0400 Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9]) by gateway34.websitewelcome.com (Postfix) with ESMTP id C471696C388 for ; Tue, 17 Jul 2018 08:43:40 -0500 (CDT) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id fQG4fwbzAbXuJfQGIf4VGJ; Tue, 17 Jul 2018 08:43:40 -0500 X-Authority-Reason: nr=8 Received: from [189.250.65.56] (port=41792 helo=embeddedor) by gator4166.hostgator.com with esmtpa (Exim 4.91) (envelope-from ) id 1ffQG3-001Aes-SY; Tue, 17 Jul 2018 08:43:16 -0500 Date: Tue, 17 Jul 2018 08:43:14 -0500 From: "Gustavo A. R. Silva" To: Jakub Kicinski , "David S. Miller" Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH] rtnetlink: fix uninitialized variable Message-ID: <20180717134314.GA31127@embeddedor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 189.250.65.56 X-Source-L: No X-Exim-ID: 1ffQG3-001Aes-SY X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedor) [189.250.65.56]:41792 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 4 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, there are execution paths in which variable err is returned without being properly initialized previously: 1417 if (rtnl_xdp_report_one(skb, dev, &prog_id, &mode, XDP_ATTACHED_SKB, 1418 IFLA_XDP_SKB_PROG_ID, rtnl_xdp_prog_skb)) 1419 goto err_cancel; 1420 if (rtnl_xdp_report_one(skb, dev, &prog_id, &mode, XDP_ATTACHED_DRV, 1421 IFLA_XDP_DRV_PROG_ID, rtnl_xdp_prog_drv)) 1422 goto err_cancel; 1423 if (rtnl_xdp_report_one(skb, dev, &prog_id, &mode, XDP_ATTACHED_HW, 1424 IFLA_XDP_HW_PROG_ID, rtnl_xdp_prog_hw)) 1425 goto err_cancel; Fix this by initializing variable err to -EMSGSIZE. Addresses-Coverity-ID: 1471831 ("Uninitialized scalar variable") Fixes: a25717d2b604 ("xdp: support simultaneous driver and hw XDP attachment") Signed-off-by: Gustavo A. R. Silva --- net/core/rtnetlink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index e03258e..648c984 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -1405,12 +1405,12 @@ static int rtnl_xdp_fill(struct sk_buff *skb, struct net_device *dev) { struct nlattr *xdp; u32 prog_id; - int err; + int err = -EMSGSIZE; u8 mode; xdp = nla_nest_start(skb, IFLA_XDP); if (!xdp) - return -EMSGSIZE; + return err; prog_id = 0; mode = XDP_ATTACHED_NONE; -- 2.7.4