From patchwork Wed Nov 29 08:47:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 10081801 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 50DE86020B for ; Wed, 29 Nov 2017 10:40:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52BA02892B for ; Wed, 29 Nov 2017 10:40:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4710528977; Wed, 29 Nov 2017 10:40:41 +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=-6.9 required=2.0 tests=BAYES_00,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 D55E22892B for ; Wed, 29 Nov 2017 10:40:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753444AbdK2Kki (ORCPT ); Wed, 29 Nov 2017 05:40:38 -0500 Received: from xavier.telenet-ops.be ([195.130.132.52]:42780 "EHLO xavier.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752804AbdK2Kkh (ORCPT ); Wed, 29 Nov 2017 05:40:37 -0500 Received: from ayla.of.borg ([84.195.106.246]) by xavier.telenet-ops.be with bizsmtp id fmgb1w00E5JzmfG01mgbrL; Wed, 29 Nov 2017 11:40:35 +0100 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.86_2) (envelope-from ) id 1eJzn8-0001qc-Ak; Wed, 29 Nov 2017 11:40:34 +0100 Received: from geert by ramsan with local (Exim 4.86_2) (envelope-from ) id 1eJy1n-0007dE-3g; Wed, 29 Nov 2017 09:47:35 +0100 From: Geert Uytterhoeven To: Tatyana Nikolova , Roland Dreier , Jason Gunthorpe , Doug Ledford Cc: Arnd Bergmann , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v2] RDMA/iwpm: Fix uninitialized error code in iwpm_send_mapinfo() Date: Wed, 29 Nov 2017 09:47:33 +0100 Message-Id: <1511945253-29296-1-git-send-email-geert@linux-m68k.org> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP With gcc-4.1.2: drivers/infiniband/core/iwpm_util.c: In function ‘iwpm_send_mapinfo’: drivers/infiniband/core/iwpm_util.c:647: warning: ‘ret’ may be used uninitialized in this function Indeed, if nl_client is not found in any of the scanned has buckets, ret will be used uninitialized. Preinitialize ret to -EINVAL to fix this. Fixes: 30dc5e63d6a5ad24 ("RDMA/core: Add support for iWARP Port Mapper user space service") Signed-off-by: Geert Uytterhoeven Reviewed-by: Tatyana Nikolova --- v2: - Use -EINVAL instead of zero, - Move the preinitialization to just before the loop, to catach future early offenders, - Drop RFC state. --- drivers/infiniband/core/iwpm_util.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/infiniband/core/iwpm_util.c b/drivers/infiniband/core/iwpm_util.c index 3c4faadb8cddd7fd..81528f64061a49df 100644 --- a/drivers/infiniband/core/iwpm_util.c +++ b/drivers/infiniband/core/iwpm_util.c @@ -654,6 +654,7 @@ int iwpm_send_mapinfo(u8 nl_client, int iwpm_pid) } skb_num++; spin_lock_irqsave(&iwpm_mapinfo_lock, flags); + ret = -EINVAL; for (i = 0; i < IWPM_MAPINFO_HASH_SIZE; i++) { hlist_for_each_entry(map_info, &iwpm_hash_bucket[i], hlist_node) {