From patchwork Thu May 23 12:44:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 2606721 Return-Path: X-Original-To: patchwork-linux-acpi@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 34181DFB78 for ; Thu, 23 May 2013 12:44:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758255Ab3EWMo5 (ORCPT ); Thu, 23 May 2013 08:44:57 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:39008 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758245Ab3EWMo4 (ORCPT ); Thu, 23 May 2013 08:44:56 -0400 Received: by mail-pb0-f46.google.com with SMTP id rq2so2861710pbb.19 for ; Thu, 23 May 2013 05:44:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding:x-gm-message-state; bh=nMKtjTwNM5Dbn7QZ5TbtO0xQE0/dz2WJWutf7t0Eny4=; b=Q0DVPHX0eneK2udn94AMxVcSunCWW253JxOeyto7IPKXHfi3YVgXHHYTGBMHqO9Us+ Ycz1IXPted1zxOaWDE1Jdg+IBDk4O6neltpEv3bv6goD4+S/o5AjIuyKZ4ThK+eXX43f DJvRvz+dpmy31hJ+Q5qbaTyTYhCO5UnJ/oi4ZJeE0JsrkQtPpgon/ApRRBVgHFrkClhC 6ftnih4xYN18QIDDNZm7wpPuwUYFfyENUFP/d6MjexI9ieYJ3njCe2ZYvKL5/ghMhE4Z bwJekeJoxsBJurl0Z0V0tcJlc8ZhFbxAxRdgV+Y0bOXqU8Fv53XKJnqI0Gt01ErC69IE BaLw== X-Received: by 10.66.162.67 with SMTP id xy3mr13046040pab.94.1369313095783; Thu, 23 May 2013 05:44:55 -0700 (PDT) Received: from [192.168.204.184] ([218.17.215.175]) by mx.google.com with ESMTPSA id q18sm12703217pao.4.2013.05.23.05.44.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 May 2013 05:44:54 -0700 (PDT) Message-ID: <519E0F2A.4070602@linaro.org> Date: Thu, 23 May 2013 20:44:26 +0800 From: Hanjun Guo User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 MIME-Version: 1.0 To: "Rafael J. Wysocki" CC: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, patches@linaro.org, linaro-kernel@lists.linaro.org Subject: [PATCH] ACPI: Fix potential NULL pointer dereference in acpi_processor_add() X-Gm-Message-State: ALoCoQmFu6qZUgrcGyRTFjxrLyUnXyPf4wyidIrTeIvdblFFNQkERlH4EHfgVal1TOMHh/R0qWGp Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org In acpi_processor_add(), get_cpu_device() will return NULL sometimes, although the chances are small, I think it should be fixed. Signed-off-by: Hanjun Guo --- drivers/acpi/processor_driver.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) goto err_clear_processor; diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c index bec717f..dd64f23 100644 --- a/drivers/acpi/processor_driver.c +++ b/drivers/acpi/processor_driver.c @@ -579,6 +579,10 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device) per_cpu(processors, pr->id) = pr; dev = get_cpu_device(pr->id); + if (!dev) { + result = -ENODEV; + goto err_clear_processor; + } if (sysfs_create_link(&device->dev.kobj, &dev->kobj, "sysdev")) { result = -EFAULT;