Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751764AbcLET7a (ORCPT ); Mon, 5 Dec 2016 14:59:30 -0500 Received: from shards.monkeyblade.net ([184.105.139.130]:49504 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751201AbcLET72 (ORCPT ); Mon, 5 Dec 2016 14:59:28 -0500 Date: Mon, 05 Dec 2016 14:59:26 -0500 (EST) Message-Id: <20161205.145926.1120588530863327322.davem@davemloft.net> To: bianpan201604@163.com Cc: Yuval.Mintz@cavium.com, ariel.elior@cavium.com, everest-linux-l2@cavium.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bianpan2016@163.com Subject: Re: [PATCH 1/1] net: ethernet: broadcom: fix improper return value From: David Miller In-Reply-To: <1480832969-5888-1-git-send-email-bianpan201604@163.com> References: <1480832969-5888-1-git-send-email-bianpan201604@163.com> X-Mailer: Mew version 6.7 on Emacs 24.5 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Mon, 05 Dec 2016 11:00:06 -0800 (PST) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1034 Lines: 29 From: Pan Bian Date: Sun, 4 Dec 2016 14:29:29 +0800 > From: Pan Bian > > Marco BNX2X_ALLOC_AND_SET(arr, lbl, func) calls kmalloc() to allocate > memory, and jumps to label "lbl" if the allocation fails. Label "lbl" > first cleans memory and then returns variable rc. Before calling the > macro, the value of variable rc is 0. Because 0 means no error, the > callers of bnx2x_init_firmware() may be misled. This patch fixes the bug, > assigning "-ENOMEM" to rc before calling macro NX2X_ALLOC_AND_SET(). > > Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=189141 > > Signed-off-by: Pan Bian Applied, but... > @@ -13505,6 +13505,7 @@ static int bnx2x_init_firmware(struct bnx2x *bp) > > /* Initialize the pointers to the init arrays */ > /* Blob */ > + rc = -ENOMEM; > BNX2X_ALLOC_AND_SET(init_data, request_firmware_exit, be32_to_cpu_n); > > /* Opcodes */ These kinds of macros which internally change control flow should always be avoided.