From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751185AbbI3EKO (ORCPT ); Wed, 30 Sep 2015 00:10:14 -0400 Received: from shards.monkeyblade.net ([149.20.54.216]:33222 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750726AbbI3EKM (ORCPT ); Wed, 30 Sep 2015 00:10:12 -0400 Date: Tue, 29 Sep 2015 21:10:11 -0700 (PDT) Message-Id: <20150929.211011.677113057504126372.davem@davemloft.net> To: wangweidong1@huawei.com Cc: sony.chacko@qlogic.com, Dept-HSGLinuxNICDev@qlogic.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, rui.xiang@huawei.com, manish.chopra@qlogic.com Subject: Re: [PATCH net-next v2 RESEND] BNX2: fix a Null Pointer for stats_blk From: David Miller In-Reply-To: <560A02FA.6030309@huawei.com> References: <56014CC0.3050201@huawei.com> <5608E5DE.6010706@huawei.com> <560A02FA.6030309@huawei.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]); Tue, 29 Sep 2015 21:10:12 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Weidong Wang Date: Tue, 29 Sep 2015 11:18:18 +0800 > @@ -839,11 +828,12 @@ bnx2_free_mem(struct bnx2 *bp) > } > > static int > -bnx2_alloc_mem(struct bnx2 *bp) > +bnx2_alloc_stats_blk(struct net_device *dev) > { > - int i, status_blk_size, err; > + int i, status_blk_size; > struct bnx2_napi *bnapi; > void *status_blk; > + struct bnx2 *bp = netdev_priv(dev); > > /* Combine status and statistics blocks into one allocation. */ > status_blk_size = L1_CACHE_ALIGN(sizeof(struct status_block)); This function is not just allocating the stats block, it's allocating a whole bunch of other things too. Only allocate the stats block at probe time, not the NAPI et al. stuff as well. That can safely stay in the open/close paths.