From patchwork Thu Aug 19 18:52:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 62213 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 9D911B70CD for ; Fri, 20 Aug 2010 04:53:16 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752970Ab0HSSxM (ORCPT ); Thu, 19 Aug 2010 14:53:12 -0400 Received: from mail-ew0-f46.google.com ([209.85.215.46]:61597 "EHLO mail-ew0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751566Ab0HSSxK (ORCPT ); Thu, 19 Aug 2010 14:53:10 -0400 Received: by ewy23 with SMTP id 23so1550296ewy.19 for ; Thu, 19 Aug 2010 11:53:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:subject :message-id:references:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=xrMYdoj/yDx+kH/5pmIqMGUpE6lfYEtA6dEez5reBYo=; b=luDOLGOk217+Vp4gjecFvW9Zck6WyL6ZlaZ7Gn2RfRvxdvdL8zwaD9fXc9HX5ng1cQ CQTeTeC6EvbIR9WzlE9GWopYncpC+uy6KKtb2tpUYD90ShaWSsLJOh4RS0aw8KO4c4vC g4cezXn9ymyPSc5d1VQoPdb7rXOIcvMRzeLDk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=F4yLzhISPdRUowaf4bIWnv7O8cc5G++Ca2evOhWpuTCIhg9GJWZ638B9wAPocXcePi sYl0n15wWUu0aPAp8EeZiLKw/SkWuTmmHVSKvW2xauFtdxq+80v36CipD/Jgh4IfgTIU X+or/EFxbLUpg2BdjwFQz6eJlzcN9MRR4oQ3M= Received: by 10.216.188.211 with SMTP id a61mr1043637wen.15.1282243989051; Thu, 19 Aug 2010 11:53:09 -0700 (PDT) Received: from bicker ([41.205.146.22]) by mx.google.com with ESMTPS id w14sm1250678weq.9.2010.08.19.11.52.56 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 19 Aug 2010 11:53:07 -0700 (PDT) Date: Thu, 19 Aug 2010 20:52:44 +0200 From: Dan Carpenter To: Linux Driver , "David S. Miller" , Breno Leitao , "netdev@vger.kernel.org" , "kernel-janitors@vger.kernel.org" , ron.mercer@qlogic.com Subject: [patch v2] qlge: pull NULL check ahead of dereference Message-ID: <20100819185244.GD6674@bicker> References: <20100819100214.GB6674@bicker> <20100819121942.GA14895@linux-ox1b.qlogic.org> <20100819125933.GB14895@linux-ox1b.qlogic.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20100819125933.GB14895@linux-ox1b.qlogic.org> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org There was a dereference before NULL check issue introduced in 1e213303d "qlge: Add tx multiqueue support." I've pulled the NULL check of "net_rsp" forward a couple lines to avoid that. Also Ron Mercer says that the early exit should be above the index write. ql_write_cq_idx(rx_ring); Signed-off-by: Dan Carpenter Signed-off-by: Ron Mercer --- v2: Moved the early exit ahead of the ql_write_cq_idx() -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/qlge/qlge_main.c b/drivers/net/qlge/qlge_main.c index 8d63f69..c9f9754 100644 --- a/drivers/net/qlge/qlge_main.c +++ b/drivers/net/qlge/qlge_main.c @@ -2222,10 +2222,11 @@ static int ql_clean_outbound_rx_ring(struct rx_ring *rx_ring) ql_update_cq(rx_ring); prod = ql_read_sh_reg(rx_ring->prod_idx_sh_reg); } + if (!net_rsp) + return 0; ql_write_cq_idx(rx_ring); tx_ring = &qdev->tx_ring[net_rsp->txq_idx]; - if (__netif_subqueue_stopped(qdev->ndev, tx_ring->wq_id) && - net_rsp != NULL) { + if (__netif_subqueue_stopped(qdev->ndev, tx_ring->wq_id)) { if (atomic_read(&tx_ring->queue_stopped) && (atomic_read(&tx_ring->tx_count) > (tx_ring->wq_len / 4))) /*