From patchwork Fri Sep 21 08:43:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yijing Wang X-Patchwork-Id: 185616 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 669D12C0088 for ; Fri, 21 Sep 2012 18:45:01 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757066Ab2IUIpA (ORCPT ); Fri, 21 Sep 2012 04:45:00 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:17068 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757052Ab2IUIpA (ORCPT ); Fri, 21 Sep 2012 04:45:00 -0400 Received: from 172.24.2.119 (EHLO szxeml207-edg.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.4-GA FastPath queued) with ESMTP id APK38279; Fri, 21 Sep 2012 16:44:53 +0800 (CST) Received: from SZXEML421-HUB.china.huawei.com (10.82.67.160) by szxeml207-edg.china.huawei.com (172.24.2.56) with Microsoft SMTP Server (TLS) id 14.1.323.3; Fri, 21 Sep 2012 16:43:59 +0800 Received: from localhost (10.135.76.84) by szxeml421-hub.china.huawei.com (10.82.67.160) with Microsoft SMTP Server id 14.1.323.3; Fri, 21 Sep 2012 16:43:51 +0800 From: Yijing Wang To: Bjorn Helgaas , Huang Ying , Chen Gong CC: , Hanjun Guo , , Yijing Wang Subject: [PATCH v5 2/5] PCI/AER: use list_for_each_entry to avoid a small race condition window Date: Fri, 21 Sep 2012 16:43:10 +0800 Message-ID: <1348216993-6948-3-git-send-email-wangyijing@huawei.com> X-Mailer: git-send-email 1.7.11.msysgit.1 In-Reply-To: <1348216993-6948-1-git-send-email-wangyijing@huawei.com> References: <1348216993-6948-1-git-send-email-wangyijing@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.135.76.84] X-CFilter-Loop: Reflected Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org When we rmmod aer_inject module, there is a small race condition window between pci_bus_ops_pop() and pci_bus_set_ops() in aer_inject_exit, eg. pci_read_aer/pci_write_aer was called between them. So keep pci_bus_ops_list until pci_bus_set_ops complete, use list_for_each_entry() instead of pci_bus_ops_pop to get bus_ops. Signed-off-by: Yijing Wang --- drivers/pci/pcie/aer/aer_inject.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/pci/pcie/aer/aer_inject.c b/drivers/pci/pcie/aer/aer_inject.c index fdab3bb..f499f01 100644 --- a/drivers/pci/pcie/aer/aer_inject.c +++ b/drivers/pci/pcie/aer/aer_inject.c @@ -543,10 +543,11 @@ static void __exit aer_inject_exit(void) misc_deregister(&aer_inject_device); - while ((bus_ops = pci_bus_ops_pop())) { + list_for_each_entry(bus_ops, &pci_bus_ops_list, list) pci_bus_set_ops(bus_ops->bus, bus_ops->ops); + + while ((bus_ops = pci_bus_ops_pop())) kfree(bus_ops); - } spin_lock_irqsave(&inject_lock, flags); list_for_each_entry_safe(err, err_next, &einjected, list) {