diff mbox

ACPI: Fix potential NULL pointer dereference in acpi_processor_add()

Message ID 519E0F2A.4070602@linaro.org
State New
Headers show

Commit Message

Hanjun Guo May 23, 2013, 12:44 p.m. UTC
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 <hanjun.guo@linaro.org>
---
 drivers/acpi/processor_driver.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

                goto err_clear_processor;

Comments

Rafael J. Wysocki May 28, 2013, 11:30 p.m. UTC | #1
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 <hanjun.guo@linaro.org>

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.

Thanks,
Rafael


> ---
>  drivers/acpi/processor_driver.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> 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;
>                 goto err_clear_processor;
>
Hanjun Guo May 29, 2013, 1:38 a.m. UTC | #2
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 <hanjun.guo@linaro.org>
> 
> 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.

Thanks
Hanjun

> 
> Thanks,
> Rafael
> 
> 
>> ---
>>  drivers/acpi/processor_driver.c |    4 ++++
>>  1 files changed, 4 insertions(+), 0 deletions(-)
>>
>> 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;
>>                 goto err_clear_processor;
>>
Martin Mokrejs May 29, 2013, 11:07 a.m. UTC | #3
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 <hanjun.guo@linaro.org>
>>
>> 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. ;)
Martin

> 
> Thanks
> Hanjun
> 
>>
>> Thanks,
>> Rafael
>>
>>
>>> ---
>>>  drivers/acpi/processor_driver.c |    4 ++++
>>>  1 files changed, 4 insertions(+), 0 deletions(-)
>>>
>>> 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;
>>>                 goto err_clear_processor;
>>>
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
>
Hanjun Guo May 30, 2013, 2:29 a.m. UTC | #4
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 <hanjun.guo@linaro.org>
>>>
>>> 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?

Thanks
Hanjun

> Martin
Rafael J. Wysocki May 30, 2013, 1:57 p.m. UTC | #5
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 <hanjun.guo@linaro.org>
> >>>
> >>> 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?

Rafael
Greg Kroah-Hartman May 30, 2013, 10:25 p.m. UTC | #6
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 <hanjun.guo@linaro.org>
> > >>>
> > >>> 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.

thanks,

greg k-h
diff mbox

Patch

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;