From patchwork Fri May 31 03:58:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 17310 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f200.google.com (mail-ve0-f200.google.com [209.85.128.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5D35725D81 for ; Fri, 31 May 2013 03:59:35 +0000 (UTC) Received: by mail-ve0-f200.google.com with SMTP id m1sf1319528ves.11 for ; Thu, 30 May 2013 20:59:34 -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:references :in-reply-to: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; bh=yWpZEGspjABgainBQY8DSwBEfJH59MKCM5lhm+1E+74=; b=myQj9z0XH388A5aqOnMRuPDiX5RceJP/11iSGJ01SjraNv16MiPVJGUTImvlBPyNgi QasQPz9ROoxLCdqNjV1g6bb2GeRH73YD4+X0NfxoiYr0MRZiyYEhVzb8AlhFbBE+IYqr qx8ATjkMJenuWLf42kcXyNOkoKwfjW3E1cktu5xscgMAVbPLWcsk57157yBBp6qBNQNZ Er/Oq7tPWSXjI4gxqqt4MnTbNGLr+D4jtMSomnnaVB9fnONTv0oN0X5HUyQjY6lGV4EO 8u4FwXcuQVX3h0RFpsgthdBCfxqTPzO/FNWZ4zWsIJK4p/imU5WybfIHylg85IMX46gU 7vQQ== X-Received: by 10.224.200.202 with SMTP id ex10mr5779416qab.8.1369972774558; Thu, 30 May 2013 20:59:34 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.105.7 with SMTP id gi7ls751798qeb.56.gmail; Thu, 30 May 2013 20:59:34 -0700 (PDT) X-Received: by 10.52.174.38 with SMTP id bp6mr6928121vdc.115.1369972774258; Thu, 30 May 2013 20:59:34 -0700 (PDT) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx.google.com with ESMTPS id wl5si26998887vec.16.2013.05.30.20.59.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 30 May 2013 20:59:34 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.174; Received: by mail-vc0-f174.google.com with SMTP id hr11so731862vcb.33 for ; Thu, 30 May 2013 20:59:34 -0700 (PDT) X-Received: by 10.52.163.207 with SMTP id yk15mr7035854vdb.42.1369972773850; Thu, 30 May 2013 20:59:33 -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.229.199 with SMTP id jj7csp34132vcb; Thu, 30 May 2013 20:59:33 -0700 (PDT) X-Received: by 10.68.212.196 with SMTP id nm4mr11153755pbc.216.1369972772323; Thu, 30 May 2013 20:59:32 -0700 (PDT) Received: from mail-pd0-f179.google.com (mail-pd0-f179.google.com [209.85.192.179]) by mx.google.com with ESMTPS id px9si14690883pbb.305.2013.05.30.20.59.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 30 May 2013 20:59:32 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.179 is neither permitted nor denied by best guess record for domain of hanjun.guo@linaro.org) client-ip=209.85.192.179; Received: by mail-pd0-f179.google.com with SMTP id q11so1492539pdj.38 for ; Thu, 30 May 2013 20:59:32 -0700 (PDT) X-Received: by 10.68.175.33 with SMTP id bx1mr4547678pbc.21.1369972771947; Thu, 30 May 2013 20:59:31 -0700 (PDT) Received: from [192.168.204.184] ([218.17.215.175]) by mx.google.com with ESMTPSA id vv6sm47735894pab.6.2013.05.30.20.59.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 30 May 2013 20:59:31 -0700 (PDT) Message-ID: <51A81FF9.8030403@linaro.org> Date: Fri, 31 May 2013 11:58:49 +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: Greg Kroah-Hartman , Martin Mokrejs , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, patches@linaro.org, linaro-kernel@lists.linaro.org Subject: Re: [PATCH] ACPI: Fix potential NULL pointer dereference in acpi_processor_add() References: <519E0F2A.4070602@linaro.org> <51A5E177.3090809@fold.natur.cuni.cz> <51A6B9A2.8090904@linaro.org> <2969934.XTKV7y9VVT@vostro.rjw.lan> <20130530222542.GD1630@kroah.com> In-Reply-To: <20130530222542.GD1630@kroah.com> X-Gm-Message-State: ALoCoQm3MOkaA9W46V/gmldg00Jy6iYIZ8O3/xAg6Uiybs0zjBIYUCoClCgwoG5Xaq+IkatDgUgR X-Original-Sender: hanjun.guo@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.174 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: , On 2013-5-31 6:25, Greg Kroah-Hartman wrote: > On Thu, May 30, 2013 at 03:57:58PM +0200, Rafael J. Wysocki wrote: >> On Thursday, May 30, 2013 10:29:54 AM Hanjun Guo wrote: >>> On 2013-5-29 19:07, Martin Mokrejs wrote: >>>> Hanjun Guo wrote: >>>>> On 2013-5-29 7:30, Rafael J. Wysocki wrote: >>>>>> On Thursday, May 23, 2013 08:44:26 PM Hanjun Guo wrote: >>>>>>> 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 >>>>>> >>>>>> This patch isn't necessary any more after the changes queued up for 3.11 >>>>>> in the acpi-hotplug branch of the linux-pm.git tree. >>>>> >>>>> Ok, I noticed your patch set, just drop my patch. >>>> >>>> But shouldn't this go to stable at least? I checked linux-3.9.4 >>>> and it applies fine. Whether this is relevant for other stable >>>> series I will leave up to somebody else. ;) >>> >>> Hi Rafeal, >>> >>> What's your opinion on Martin's suggestion? >> >> Well, this is kind of hard to say. We generally don't apply patches to -stable >> that don't have mainline counterparts. >> >> Greg, I wonder what your opinion is? > > We do not apply patches to -stable that are not in Linus's tree, unless > there is no problem in Linus's tree due to a major rewrite of the code, > and it has been confirmed that the same problem isn't there. Hi Rafael, I found that the problem is still there in your acpi-hotplug tree, sorry for I didn't noticed early. I made a patch for this again, I hope it will make sense to you. The patch is attached, based on your acpi-hotplug tree. Thanks Hanjun >From 975e30f5906a883e533e4226d8eca1c449c7366b Mon Sep 17 00:00:00 2001 From: Hanjun Guo Date: Fri, 31 May 2013 11:36:08 +0800 Subject: [PATCH 1/1] ACPI / processor: Fix potential NULL pointer dereference in acpi_processor_add() In acpi_processor_add(), get_cpu_device() will return NULL in some cases, and ACPI_HANDLE_SET() just use the return dev directly, this will case a potential NULL pointer dereference, fix it. Signed-off-by: Hanjun Guo --- drivers/acpi/acpi_processor.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index 587d2af..4466b36 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -389,6 +389,11 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device, per_cpu(processor_device_array, pr->id) = device; dev = get_cpu_device(pr->id); + if (!dev) { + result = -ENODEV; + goto err; + } + ACPI_HANDLE_SET(dev, pr->handle); result = acpi_bind_one(dev, NULL); if (result)