From patchwork Tue May 28 14:24:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 10965061 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 275F092A for ; Tue, 28 May 2019 14:25:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1909E2882A for ; Tue, 28 May 2019 14:25:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D3CC28842; Tue, 28 May 2019 14:25:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B70F51FE95 for ; Tue, 28 May 2019 14:25:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727467AbfE1OZI (ORCPT ); Tue, 28 May 2019 10:25:08 -0400 Received: from albert.telenet-ops.be ([195.130.137.90]:39124 "EHLO albert.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727605AbfE1OYo (ORCPT ); Tue, 28 May 2019 10:24:44 -0400 Received: from ramsan ([84.194.111.163]) by albert.telenet-ops.be with bizsmtp id HqQS2000E3XaVaC06qQSub; Tue, 28 May 2019 16:24:41 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan with esmtp (Exim 4.90_1) (envelope-from ) id 1hVd1e-00058P-7H; Tue, 28 May 2019 16:24:26 +0200 Received: from geert by rox.of.borg with local (Exim 4.90_1) (envelope-from ) id 1hVd1e-00057Z-4f; Tue, 28 May 2019 16:24:26 +0200 From: Geert Uytterhoeven To: Igor Konopko , David Howells , "Mohit P . Tahiliani" , Takashi Sakamoto , Eran Ben Elisha , Matias Bjorling , Jiri Pirko , "David S . Miller" , Jamal Hadi Salim , Cong Wang , Clemens Ladisch , Jaroslav Kysela , Takashi Iwai , Joe Perches , Arnd Bergmann , Dan Carpenter Cc: linux-block@vger.kernel.org, netdev@vger.kernel.org, linux-afs@lists.infradead.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 5/5] [RFC] devlink: Fix uninitialized error code in devlink_fmsg_prepare_skb() Date: Tue, 28 May 2019 16:24:24 +0200 Message-Id: <20190528142424.19626-6-geert@linux-m68k.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190528142424.19626-1-geert@linux-m68k.org> References: <20190528142424.19626-1-geert@linux-m68k.org> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP With gcc 4.1: net/core/devlink.c: In function ‘devlink_fmsg_prepare_skb’: net/core/devlink.c:4325: warning: ‘err’ may be used uninitialized in this function Indeed, if the list has less than *start entries, an uninitialized error code will be returned. Fix this by preinitializing err to zero. Fixes: 1db64e8733f65381 ("devlink: Add devlink formatted message (fmsg) API") Signed-off-by: Geert Uytterhoeven Reviewed-by: Eran Ben Elisha Acked-by: Jiri Pirko --- I don't know if this can really happen, and if this is the right fix. Perhaps err should be initialized to some valid error code instead? --- net/core/devlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/devlink.c b/net/core/devlink.c index d43bc52b8840d76b..91377e4eae9a43c1 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -4321,8 +4321,8 @@ devlink_fmsg_prepare_skb(struct devlink_fmsg *fmsg, struct sk_buff *skb, { struct devlink_fmsg_item *item; struct nlattr *fmsg_nlattr; + int err = 0; int i = 0; - int err; fmsg_nlattr = nla_nest_start_noflag(skb, DEVLINK_ATTR_FMSG); if (!fmsg_nlattr)