From patchwork Sat Oct 6 15:27:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 1558531 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 70A83DF238 for ; Sat, 6 Oct 2012 15:37:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754707Ab2JFPfT (ORCPT ); Sat, 6 Oct 2012 11:35:19 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:42425 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754527Ab2JFPfO (ORCPT ); Sat, 6 Oct 2012 11:35:14 -0400 Received: by mail-pa0-f46.google.com with SMTP id hz1so2755784pad.19 for ; Sat, 06 Oct 2012 08:35:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=8a8zw5qIXrS2b0hn8wjJsndiCyguXgYqXKX0pXSjxjw=; b=L6J/JGgKNDRIovrOavsPiqgevpQd7J3K0cwN6xtFndGgEqfLuEZYyZ/OwUotlXVrFP u0wpSRjYpxRx1t+wi6yT3mthU8SpVBYebAL1GPcKsb/K/vXjBtR3BKs/Pa1G1A5Xg6B5 4ioYY2h9Ne73fnZJRXAGUZrXRxUrVBCtd6b3WNcu4pOqz2N4zWdjIG4hSn/vZGytsXhr Lwyb23HG+7Fy4ThJY1/QpiFpAcmf4svwFn0Upkho1URVch/G9r55mAZU7pfnyynUvdMS Un/gLGu0FYfFerqie8RLKJwxIUXO9GavZu4e19uTqXcGjKMtbDGoJLyR6nfMAELB4+pI i8ow== Received: by 10.68.225.34 with SMTP id rh2mr39408501pbc.78.1349537714081; Sat, 06 Oct 2012 08:35:14 -0700 (PDT) Received: from localhost.localdomain ([221.221.24.247]) by mx.google.com with ESMTPS id vz8sm7785292pbc.63.2012.10.06.08.34.58 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 06 Oct 2012 08:35:13 -0700 (PDT) From: Jiang Liu To: Yinghai Lu , Yasuaki Ishimatsu , Kenji Kaneshige , Wen Congyang , Tang Chen , Taku Izumi Cc: Hanjun Guo , Yijing Wang , Gong Chen , Jiang Liu , Tony Luck , Huang Ying , Bob Moore , Len Brown , "Srivatsa S . Bhat" , Bjorn Helgaas , linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org Subject: [RFC PATCH v3 22/28] ACPIHP/processor: protect accesses to device->driver_data Date: Sat, 6 Oct 2012 23:27:30 +0800 Message-Id: <1349537256-21670-23-git-send-email-jiang.liu@huawei.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1349537256-21670-1-git-send-email-jiang.liu@huawei.com> References: <1349537256-21670-1-git-send-email-jiang.liu@huawei.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org CPU hotplug notification handler acpi_cpu_soft_notify() and driver unbind method acpi_processor_remove() may be concurrently called. acpi_cpu_soft_notify() will access device->driver_data, but that data structure may be destroyed by acpi_processor_remove(). On the other hand, acpi_cpu_soft_notify() is always called under protection of get_online_cpus(), so use get_online_cpus() to serialize all accesses and modifications to device->driver_data. Signed-off-by: Jiang Liu --- drivers/acpi/processor_driver.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c index 4f2fec0..110c5ac 100644 --- a/drivers/acpi/processor_driver.c +++ b/drivers/acpi/processor_driver.c @@ -616,6 +616,8 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device) return 0; BUG_ON((pr->id >= nr_cpu_ids) || (pr->id < 0)); + /* block CPU online/offline operations */ + get_online_cpus(); result = acpi_processor_link(device, pr); if (result) goto err_unlock; @@ -624,6 +626,7 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device) if (result) goto err_unlink; } + put_online_cpus(); return 0; @@ -654,8 +657,10 @@ static int acpi_processor_remove(struct acpi_device *device, int type) return -EINVAL; } - acpi_processor_stop(device, pr); + get_online_cpus(); + acpi_processor_stop(pr); acpi_processor_unlink(device, pr); + put_online_cpus(); free: device->driver_data = NULL;