From patchwork Fri Dec 13 01:54:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasesh Mody X-Patchwork-Id: 300838 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 9C8B42C00A0 for ; Fri, 13 Dec 2013 12:55:41 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751987Ab3LMBzh (ORCPT ); Thu, 12 Dec 2013 20:55:37 -0500 Received: from mx0b-000f0801.pphosted.com ([67.231.152.113]:7315 "EHLO mx0b-000f0801.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751784Ab3LMBzb (ORCPT ); Thu, 12 Dec 2013 20:55:31 -0500 Received: from pps.filterd (m0000700 [127.0.0.1]) by mx0b-000f0801.pphosted.com (8.14.5/8.14.5) with SMTP id rBD1l7Oi008754; Thu, 12 Dec 2013 17:55:29 -0800 Received: from hq1wp-exchub01.corp.brocade.com ([144.49.131.13]) by mx0b-000f0801.pphosted.com with ESMTP id 1gpwn39g6g-2 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Thu, 12 Dec 2013 17:55:29 -0800 Received: from blc-10-1.brocade.com (10.70.4.101) by HQ1WP-EXCHUB01.corp.brocade.com (10.70.36.101) with Microsoft SMTP Server (TLS) id 14.3.123.3; Thu, 12 Dec 2013 17:55:28 -0800 Received: from blc-10-1.brocade.com (localhost.localdomain [127.0.0.1]) by blc-10-1.brocade.com (8.13.1/8.13.8) with ESMTP id rBD1tStE018734; Thu, 12 Dec 2013 17:55:28 -0800 Received: (from rmody@localhost) by blc-10-1.brocade.com (8.13.1/8.13.8/Submit) id rBD1tS22018731; Thu, 12 Dec 2013 17:55:28 -0800 From: Rasesh Mody To: CC: , , Rasesh Mody Subject: [net-next 08/12] bna: Add NULL Check Before Dereferencing TCB Date: Thu, 12 Dec 2013 17:54:34 -0800 Message-ID: <1386899678-18591-9-git-send-email-rmody@brocade.com> X-Mailer: git-send-email 1.8.3.rc2 In-Reply-To: <1386899678-18591-1-git-send-email-rmody@brocade.com> References: <1386899678-18591-1-git-send-email-rmody@brocade.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.11.87, 1.0.14, 0.0.0000 definitions=2013-12-13_01:2013-12-13, 2013-12-12, 1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=1 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=7.0.1-1305240000 definitions=main-1312120144 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Currently we already check to see whether the BNAD_TXQ_TX_STARTED cleared. But if the tcb structure which contains this flag is also already freed by that time, we would dereference the NULL pointer. This patch is to check tcb for NULL pointer, before dereferencing it. Signed-off-by: Rasesh Mody --- drivers/net/ethernet/brocade/bna/bnad.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/brocade/bna/bnad.c b/drivers/net/ethernet/brocade/bna/bnad.c index 14b5a9e..89a5a91 100644 --- a/drivers/net/ethernet/brocade/bna/bnad.c +++ b/drivers/net/ethernet/brocade/bna/bnad.c @@ -2942,21 +2942,21 @@ bnad_start_xmit(struct sk_buff *skb, struct net_device *netdev) } tcb = bnad->tx_info[0].tcb[txq_id]; - q_depth = tcb->q_depth; - prod = tcb->producer_index; - - unmap_q = tcb->unmap_q; /* * Takes care of the Tx that is scheduled between clearing the flag * and the netif_tx_stop_all_queues() call. */ - if (unlikely(!test_bit(BNAD_TXQ_TX_STARTED, &tcb->flags))) { + if (unlikely(!tcb || !test_bit(BNAD_TXQ_TX_STARTED, &tcb->flags))) { dev_kfree_skb(skb); BNAD_UPDATE_CTR(bnad, tx_skb_stopping); return NETDEV_TX_OK; } + q_depth = tcb->q_depth; + prod = tcb->producer_index; + unmap_q = tcb->unmap_q; + vectors = 1 + skb_shinfo(skb)->nr_frags; wis = BNA_TXQ_WI_NEEDED(vectors); /* 4 vectors per work item */