lkml.org 
[lkml]   [2018]   [Mar]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] ssb:: use put_device() if device_register fail
From
Date


On Wednesday 07 March 2018 10:17 PM, Michael Büsch wrote:
> On Wed, 7 Mar 2018 15:31:30 +0530
> Arvind Yadav <arvind.yadav.cs@gmail.com> wrote:
>
>> if device_register() returned an error! Always use put_device()
>> to give up the reference initialized.
>>
>> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
>> ---
>> drivers/ssb/main.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/ssb/main.c b/drivers/ssb/main.c
>> index 65420a9..c4449e0 100644
>> --- a/drivers/ssb/main.c
>> +++ b/drivers/ssb/main.c
>> @@ -521,6 +521,7 @@ static int ssb_devices_register(struct ssb_bus *bus)
>> ssb_err("Could not register %s\n", dev_name(dev));
>> /* Set dev to NULL to not unregister
>> * dev on error unwinding. */
>> + put_device(dev);
>> sdev->dev = NULL;
>> kfree(devwrap);
>> goto error;
>
> I don't think this is correct.
> The dev structure is allocated as part of devwrap, which is freed here.
>
> Why do you think we need put_device here?
>
Yes this patch is not correct, We must not use kfree() after you called
device_register() (even
if it was not successful!) -- see the comment for device_register().
I will delete kfree() and send updated patch.

~arvind

\
 
 \ /
  Last update: 2018-03-07 18:16    [W:0.084 / U:1.552 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site