From patchwork Tue Oct 9 05:54:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Len Brown X-Patchwork-Id: 1568291 Return-Path: X-Original-To: patchwork-linux-acpi@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 8EBB84025F for ; Tue, 9 Oct 2012 06:04:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753326Ab2JIGEA (ORCPT ); Tue, 9 Oct 2012 02:04:00 -0400 Received: from mail-qa0-f46.google.com ([209.85.216.46]:49201 "EHLO mail-qa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753010Ab2JIGD4 (ORCPT ); Tue, 9 Oct 2012 02:03:56 -0400 Received: by mail-qa0-f46.google.com with SMTP id c26so2928969qad.19 for ; Mon, 08 Oct 2012 23:03:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:in-reply-to:references:reply-to:organization; bh=tZIjEDkJs1pmtDHp8IW6JTJRbIiVLP4tnpOgEvdHfAY=; b=ySU2qsQDHK11twM+kq/dSR8AYSZUeA5Z2v4n8D7uZAjRHVzakigaT5Dki/GYIVvIQB 0rYTeBCzzCBzerw+fuU2fhw3944ul23Hn9h/est2EwcDK02y5fp6Q7i6ypPawVhQ5QxG lPsjgb3X1AXWruseFWcNMUNt92plkpMeMKXXFqGnhElqH4V5532yzEQdpPa49iDCrKbH JwlK8mC+zV2Tzw0nQxnwp01v0AnqPcOSv+uUj57d8/gfVbVfa+C52ZDo9JXFI1Zi2r21 8V2CpxBQr8aCAOVizMVpdwwUbDHAOCziZ8fZK7083ooBZh671NeeUGJiVDBVm2d3nzaH wr0w== Received: by 10.229.204.25 with SMTP id fk25mr1584248qcb.18.1349762635452; Mon, 08 Oct 2012 23:03:55 -0700 (PDT) Received: from x980.localdomain6 (pool-74-104-146-186.bstnma.fios.verizon.net. [74.104.146.186]) by mx.google.com with ESMTPS id ck11sm20206037qab.17.2012.10.08.23.03.46 (version=SSLv3 cipher=OTHER); Mon, 08 Oct 2012 23:03:54 -0700 (PDT) From: Len Brown To: linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Wei Yongjun , Len Brown Subject: [PATCH 28/30] cpuidle / ACPI: fix potential NULL pointer dereference Date: Tue, 9 Oct 2012 01:54:18 -0400 Message-Id: X-Mailer: git-send-email 1.8.0.rc1 In-Reply-To: <1349762060-25334-1-git-send-email-lenb@kernel.org> References: <1349762060-25334-1-git-send-email-lenb@kernel.org> In-Reply-To: References: Reply-To: Len Brown Organization: Intel Open Source Technology Center Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Wei Yongjun The dereference should be moved below the NULL test. dpatch engine is used to auto generate this patch. (https://github.com/weiyj/dpatch) Signed-off-by: Wei Yongjun Signed-off-by: Len Brown --- drivers/acpi/processor_idle.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 3655ab9..e8086c7 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c @@ -1132,7 +1132,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr) int acpi_processor_hotplug(struct acpi_processor *pr) { int ret = 0; - struct cpuidle_device *dev = per_cpu(acpi_cpuidle_device, pr->id); + struct cpuidle_device *dev; if (disabled_by_idle_boot_param()) return 0; @@ -1147,6 +1147,7 @@ int acpi_processor_hotplug(struct acpi_processor *pr) if (!pr->flags.power_setup_done) return -ENODEV; + dev = per_cpu(acpi_cpuidle_device, pr->id); cpuidle_pause_and_lock(); cpuidle_disable_device(dev); acpi_processor_get_power_info(pr);