From patchwork Wed Sep 12 12:33:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yijing Wang X-Patchwork-Id: 1443421 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 059B14025E for ; Wed, 12 Sep 2012 12:35:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755256Ab2ILMfq (ORCPT ); Wed, 12 Sep 2012 08:35:46 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:61024 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754776Ab2ILMfp (ORCPT ); Wed, 12 Sep 2012 08:35:45 -0400 Received: from 172.24.2.119 (EHLO szxeml212-edg.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.4-GA FastPath queued) with ESMTP id AOX24751; Wed, 12 Sep 2012 20:35:41 +0800 (CST) Received: from SZXEML422-HUB.china.huawei.com (10.82.67.161) by szxeml212-edg.china.huawei.com (172.24.2.181) with Microsoft SMTP Server (TLS) id 14.1.323.3; Wed, 12 Sep 2012 20:34:36 +0800 Received: from localhost (10.135.76.84) by szxeml422-hub.china.huawei.com (10.82.67.161) with Microsoft SMTP Server id 14.1.323.3; Wed, 12 Sep 2012 20:34:24 +0800 From: Yijing Wang To: Bjorn Helgaas , Huang Ying , Chen Gong CC: , Hanjun Guo , , Yijing Wang Subject: [PATCH v2 4/4] PCI/AER: fix a small race condition window when rmmod aer_inject Date: Wed, 12 Sep 2012 20:33:45 +0800 Message-ID: <1347453225-7704-4-git-send-email-wangyijing@huawei.com> X-Mailer: git-send-email 1.7.11.msysgit.1 In-Reply-To: <1347453225-7704-1-git-send-email-wangyijing@huawei.com> References: <1347453225-7704-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 Fix a small race condition window between pci_bus_ops_pop() and pci_bus_set_ops() functions. Signed-off-by: Yijing Wang Signed-off-by: Jiang Liu --- drivers/pci/pcie/aer/aer_inject.c | 8 ++------ 1 files changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/pci/pcie/aer/aer_inject.c b/drivers/pci/pcie/aer/aer_inject.c index bd043db..69c2d77 100644 --- a/drivers/pci/pcie/aer/aer_inject.c +++ b/drivers/pci/pcie/aer/aer_inject.c @@ -141,12 +141,11 @@ static struct pci_ops *__find_pci_bus_ops(struct pci_bus *bus) return NULL; } +/* inject_lock must be held before calling */ static struct pci_bus_ops *pci_bus_ops_pop(void) { - unsigned long flags; struct pci_bus_ops *bus_ops = NULL; - spin_lock_irqsave(&inject_lock, flags); if (list_empty(&pci_bus_ops_list)) bus_ops = NULL; else { @@ -154,7 +153,6 @@ static struct pci_bus_ops *pci_bus_ops_pop(void) list_del(lh); bus_ops = list_entry(lh, struct pci_bus_ops, list); } - spin_unlock_irqrestore(&inject_lock, flags); return bus_ops; } @@ -610,14 +608,12 @@ static void __exit aer_inject_exit(void) bus_unregister_notifier(&pci_bus_type, &aerinj_hp_notifier); misc_deregister(&aer_inject_device); + spin_lock_irqsave(&inject_lock, flags); while ((bus_ops = pci_bus_ops_pop())) { pci_bus_set_ops(bus_ops->bus, bus_ops->ops); kfree(bus_ops); } - clean_untracked_pci_aer_ops(); - - spin_lock_irqsave(&inject_lock, flags); list_for_each_entry_safe(err, err_next, &einjected, list) { list_del(&err->list); kfree(err);