From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756108AbbIWWbW (ORCPT ); Wed, 23 Sep 2015 18:31:22 -0400 Received: from shards.monkeyblade.net ([149.20.54.216]:46142 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754977AbbIWWbV (ORCPT ); Wed, 23 Sep 2015 18:31:21 -0400 Date: Wed, 23 Sep 2015 15:31:17 -0700 (PDT) Message-Id: <20150923.153117.2291008783799112683.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 Subject: Re: [PATCH net-next] BNX2: fix a Null Pointer for stats_blk From: David Miller In-Reply-To: <56014CC0.3050201@huawei.com> References: <56014CC0.3050201@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]); Wed, 23 Sep 2015 15:31:20 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Weidong Wang Date: Tue, 22 Sep 2015 20:42:40 +0800 > @@ -880,6 +882,7 @@ bnx2_alloc_mem(struct bnx2 *bp) > } > } > > + spin_lock(&bp->stats64_lock); > bp->stats_blk = status_blk + status_blk_size; > > bp->stats_blk_mapping = bp->status_blk_mapping + status_blk_size; > @@ -894,20 +897,23 @@ bnx2_alloc_mem(struct bnx2 *bp) > &bp->ctx_blk_mapping[i], > GFP_KERNEL); > if (bp->ctx_blk[i] == NULL) > - goto alloc_mem_err; > + goto free_stats64_lock; > } > } > > err = bnx2_alloc_rx_mem(bp); > if (err) > - goto alloc_mem_err; > + goto free_stats64_lock; You're holding a spinlock while doing GFP_KERNEL allocations. Second of all, taking a spinlock in get_stats64() defeats the whole intention of making statistics acquisition as fast and as SMP scalable as possible.