From patchwork Sun Nov 4 15:23:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 1694621 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 7AD9A3FD2B for ; Sun, 4 Nov 2012 15:26:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755030Ab2KDPYh (ORCPT ); Sun, 4 Nov 2012 10:24:37 -0500 Received: from mail-da0-f46.google.com ([209.85.210.46]:40017 "EHLO mail-da0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754953Ab2KDPYe (ORCPT ); Sun, 4 Nov 2012 10:24:34 -0500 Received: by mail-da0-f46.google.com with SMTP id n41so2322643dak.19 for ; Sun, 04 Nov 2012 07:24:34 -0800 (PST) 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=K0cyJr/ThOCV6+HfN5/FkfFOrP36U1ZmaBpjY8HGMRI=; b=0QcFW6R/tYIrGn/VtyE1G+mK+1HTgVdNY0RrDVUn6HPMwz7Yh7au2NGnx4gRIj8BQz JqOjfvZGDLCLisRXTnLmKtQTUlq5M4QX7Jl6e2cB5lOo2jnen+Sh4FEaM9a0xgxDbx5Q QwFHPGcbWlyF00OTYIpAVEDTCc7Qpm5yd0oMoa1Iox+fiUNBxij5xBU6PqeiPo14UB9r oSe9Xb44++2nctU8Avs2uT3/pOk0i5E576bh7ZmUwBi2gJxQj41pg45WKkrHoqlR6N1T dmtnr39CYc4n+zgKnBJ02wU35PCqvb+dvsGa52IIn5vWIgVfFsGRToa6GFWsv/kxde1m tCEg== Received: by 10.68.223.66 with SMTP id qs2mr22439734pbc.139.1352042674314; Sun, 04 Nov 2012 07:24:34 -0800 (PST) Received: from localhost.localdomain ([120.196.98.117]) by mx.google.com with ESMTPS id nd6sm9020763pbc.68.2012.11.04.07.24.29 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 04 Nov 2012 07:24:33 -0800 (PST) From: Jiang Liu To: "Rafael J . Wysocki" , Yinghai Lu , Tony Luck , Yasuaki Ishimatsu , Wen Congyang , Tang Chen , Taku Izumi , Bjorn Helgaas Cc: Jiang Liu , Kenji Kaneshige , Huang Ying , Bob Moore , Len Brown , "Srivatsa S . Bhat" , Yijing Wang , Hanjun Guo , Jiang Liu , linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org Subject: [ACPIHP PATCH part4 3/9] ACPIHP/processor: protect accesses to device->driver_data Date: Sun, 4 Nov 2012 23:23:56 +0800 Message-Id: <1352042642-7306-4-git-send-email-jiang.liu@huawei.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1352042642-7306-1-git-send-email-jiang.liu@huawei.com> References: <1352042642-7306-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 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c index 28add34..7d6d794 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; } + get_online_cpus(); acpi_processor_stop(device, pr); acpi_processor_unlink(device, pr); + put_online_cpus(); free: device->driver_data = NULL;