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: 17123 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D24702395B for ; Thu, 23 May 2013 12:45:56 +0000 (UTC) Received: by mail-la0-f70.google.com with SMTP id fo13sf2373471lab.9 for ; Thu, 23 May 2013 05:45:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-beenthere:x-forwarded-to:x-forwarded-for:delivered-to:message-id :date:from:user-agent:mime-version:to:cc:subject:x-gm-message-state :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:x-google-group-id:list-post:list-help :list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=nMKtjTwNM5Dbn7QZ5TbtO0xQE0/dz2WJWutf7t0Eny4=; b=Ie1/aQQ7ptX5lLDvggxJQSnQykL0giqGT1cMugzB68dN+sLQEkqcKR3ifCechUlWQx qm2uCYR8zALUFeMbXjoEn9j4KvC7qoBKQ8XLCVjr59YJePLfoj9mn72ZKee5hPMdyvgT qXPSYd8a0Dk6nYjgLaThGSerOHa3WfVdzu2XPHaQyCGoSlKYPBUysD/+VuNljBKqbquf hmahnHtYkVQ9cYITlreWxRmY2W7eNzR5I5yJqZUQzSHhbP5u3MUQRw2PnXvhJVPydinP 6QA58tYWSutS+QLlqbOrUUf8w3wwe3slc8EyN//H2Vni2uhzSBpmYrZo3yDhY5ASLSMj MzTA== X-Received: by 10.180.109.111 with SMTP id hr15mr3458965wib.1.1369313100113; Thu, 23 May 2013 05:45:00 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.180.21.145 with SMTP id v17ls1832520wie.45.canary; Thu, 23 May 2013 05:45:00 -0700 (PDT) X-Received: by 10.180.90.43 with SMTP id bt11mr19016016wib.30.1369313100055; Thu, 23 May 2013 05:45:00 -0700 (PDT) Received: from mail-ve0-x230.google.com (mail-ve0-x230.google.com [2607:f8b0:400c:c01::230]) by mx.google.com with ESMTPS id k11si4760429wiw.30.2013.05.23.05.44.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 May 2013 05:45:00 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::230 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::230; Received: by mail-ve0-f176.google.com with SMTP id jz10so2332180veb.35 for ; Thu, 23 May 2013 05:44:59 -0700 (PDT) X-Received: by 10.52.69.200 with SMTP id g8mr4311728vdu.4.1369313098184; Thu, 23 May 2013 05:44:58 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.126.138 with SMTP id c10csp49466vcs; Thu, 23 May 2013 05:44:56 -0700 (PDT) X-Received: by 10.68.192.1 with SMTP id hc1mr12607058pbc.45.1369313096545; Thu, 23 May 2013 05:44:56 -0700 (PDT) Received: from mail-pb0-x22c.google.com (mail-pb0-x22c.google.com [2607:f8b0:400e:c01::22c]) by mx.google.com with ESMTPS id kx5si8997568pbc.20.2013.05.23.05.44.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 May 2013 05:44:56 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400e:c01::22c is neither permitted nor denied by best guess record for domain of hanjun.guo@linaro.org) client-ip=2607:f8b0:400e:c01::22c; Received: by mail-pb0-f44.google.com with SMTP id wz12so2866490pbc.17 for ; Thu, 23 May 2013 05:44:55 -0700 (PDT) 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: ALoCoQmVnCeIByCZTGJneRdprXzeJt4QLHdQwel5uLfSJBeFJZqRZiQyfH0KOM7n7pyb+R9gkUYW X-Original-Sender: hanjun.guo@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::230 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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;