Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753174Ab1BEDS7 (ORCPT ); Fri, 4 Feb 2011 22:18:59 -0500 Received: from exht1.emulex.com ([138.239.113.183]:13211 "EHLO exht1.ad.emulex.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751523Ab1BEDS5 (ORCPT ); Fri, 4 Feb 2011 22:18:57 -0500 Date: Fri, 4 Feb 2011 21:18:28 -0600 From: Ajit Khaparde To: , CC: Subject: Re: [PATCH] ServerEngines, benet: Avoid potential null deref in be_cmd_get_seeprom_data() Message-ID: <20110205031828.GA12772@akhaparde-VBox> Reply-To: Ajit Khaparde MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline X-URL: http://www.emulex.com Organization: Emulex Corp User-Agent: "Ajit's Mutt" X-OS: Linux i686 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1800 Lines: 58 > From: Jesper Juhl [jj@chaosbits.net] > ent: Thursday, February 03, 2011 3:27 PM > To: netdev@vger.kernel.org > Cc: linux-drivers; linux-kernel@vger.kernel.org; Khaparde, Ajit; Bandi, Sarveshwar; Seetharaman, Subramanian; Perla, Sathya > Subject: [PATCH] ServerEngines, benet: Avoid potential null deref in be_cmd_get_seeprom_data() > wrb_from_mccq() may return null, so we may crash on a null deref in > be_cmd_get_seeprom_data(). > This avoids that potential crash. > Signed-off-by: Jesper Juhl Thanks Jesper. But because we have acquired a lock, we need to release it. I would suggest considering the following patch. --- [PATCH] ServerEngines, benet: Avoid potential null deref in be_cmd_get_seeprom_data() Found by: Jesper Juhl Signed-off-by: Ajit Khaparde --- drivers/net/benet/be_cmds.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/drivers/net/benet/be_cmds.c b/drivers/net/benet/be_cmds.c index 0c7811f..a179cc6 100644 --- a/drivers/net/benet/be_cmds.c +++ b/drivers/net/benet/be_cmds.c @@ -1786,6 +1786,10 @@ int be_cmd_get_seeprom_data(struct be_adapter *adapter, spin_lock_bh(&adapter->mcc_lock); wrb = wrb_from_mccq(adapter); + if (!wrb) { + status = -EBUSY; + goto err; + } req = nonemb_cmd->va; sge = nonembedded_sgl(wrb); @@ -1801,6 +1805,7 @@ int be_cmd_get_seeprom_data(struct be_adapter *adapter, status = be_mcc_notify_wait(adapter); +err: spin_unlock_bh(&adapter->mcc_lock); return status; } -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/