From patchwork Wed May 25 19:09:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hotran X-Patchwork-Id: 9136095 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 016B56075C for ; Wed, 25 May 2016 19:10:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EACB528110 for ; Wed, 25 May 2016 19:10:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF65E282C0; Wed, 25 May 2016 19:10:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8464928110 for ; Wed, 25 May 2016 19:10:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751839AbcEYTKe (ORCPT ); Wed, 25 May 2016 15:10:34 -0400 Received: from mail-pf0-f175.google.com ([209.85.192.175]:35044 "EHLO mail-pf0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751485AbcEYTKc (ORCPT ); Wed, 25 May 2016 15:10:32 -0400 Received: by mail-pf0-f175.google.com with SMTP id g64so21390843pfb.2 for ; Wed, 25 May 2016 12:10:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apm.com; s=apm; h=from:to:cc:subject:date:message-id; bh=HI7buVlmFASs73EoTm8YVWbTEMxcLGzTUkUoVheDQ+Y=; b=IJfuKIwr1S/AwRZQSgOrT//bQnEGQ2d/twby+hn91qpOFFuBjt4tgSZlVf484/EE4v WaRGg3Y2FkGePvvTqvSLC8U4XMLN2/95Minkl7lob0aUNUv418/tX7t4v2ssnwKk5Zxm JowG7YPKXo9tRLIpSYyG9otAqqHbTy2inc10E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=HI7buVlmFASs73EoTm8YVWbTEMxcLGzTUkUoVheDQ+Y=; b=Y0ZVPedRcQz571r00h8iKqWxsUh1b0qBc7qmE9w/9C5qdKNb6WsWzFql/8tGfO0D9t J/OrrMWIKyHvD/QBgI7OShr9jDjRYd/OKBdoXwUy+8EpthXtzs9eMHDydmEKMeIgOCO5 9srq+3HcT6q40DewufhiOgGxcfpMODrA3t3Px5tbA6pi38Bfy3qqsWZIJnAaRPakfhCy ZpTO0ZygzjFpTs8GgRUeiEINT9CFtbSTcDFwtn19NCRCHEZtpWAEtpuyhBwF4/JnaEV7 2yp3WR9wHFP7/YE7Sgc5GoULk8xp/uAM+F4NfHDcVB3bcdNpfGdtDsiBk4IMpVBg/Pra mqlw== X-Gm-Message-State: ALyK8tKh6KrRRlC+QaTeOyLXBAilLt+KJeDiRmwWRNxI5J4pkHTykGPHC2OnZG29jSejBhDQ X-Received: by 10.98.54.199 with SMTP id d190mr8054545pfa.151.1464203430862; Wed, 25 May 2016 12:10:30 -0700 (PDT) Received: from hotran_localhost.amcc.com ([206.80.4.98]) by smtp.gmail.com with ESMTPSA id fn3sm14549227pab.20.2016.05.25.12.10.29 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 25 May 2016 12:10:30 -0700 (PDT) From: Hoan Tran To: "Rafael J. Wysocki" , Len Brown , Ashwin Chaugule Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Duc Dang , lho@apm.com, Hoan Tran Subject: [PATCH] acpi: cppc: Prevent cpc_desc_ptr points to the invalid data Date: Wed, 25 May 2016 12:09:23 -0700 Message-Id: <1464203363-20599-1-git-send-email-hotran@apm.com> X-Mailer: git-send-email 1.9.1 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When CPPC fails to request PCC channel, the CPC data is freed and cpc_desc_ptr points to the invalid data. This change prevents this issue by moving cpc_desc_ptr assignment after PCC channel request. Signed-off-by: Hoan Tran Acked-by: Ashwin Chaugule --- drivers/acpi/cppc_acpi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index 8adac69..85fd8f7 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -595,9 +595,6 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr) /* Store CPU Logical ID */ cpc_ptr->cpu_id = pr->id; - /* Plug it into this CPUs CPC descriptor. */ - per_cpu(cpc_desc_ptr, pr->id) = cpc_ptr; - /* Parse PSD data for this CPU */ ret = acpi_get_psd(cpc_ptr, handle); if (ret) @@ -610,6 +607,9 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr) goto out_free; } + /* Plug PSD data into this CPUs CPC descriptor. */ + per_cpu(cpc_desc_ptr, pr->id) = cpc_ptr; + /* Everything looks okay */ pr_debug("Parsed CPC struct for CPU: %d\n", pr->id);