* [PATCH] driver core: Free memory obtained by kzalloc
@ 2018-03-01 5:59 Arvind Yadav
2018-03-01 10:54 ` Andy Shevchenko
0 siblings, 1 reply; 3+ messages in thread
From: Arvind Yadav @ 2018-03-01 5:59 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel
Here kfree() is taking NULL. So moving 'dev = NULL' after kfree().
Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
drivers/base/bus.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index ef61833..ccb64a0 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -1170,9 +1170,9 @@ static int subsys_register(struct bus_type *subsys,
err_dev_reg:
put_device(dev);
- dev = NULL;
err_name:
kfree(dev);
+ dev = NULL;
err_dev:
bus_unregister(subsys);
return err;
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] driver core: Free memory obtained by kzalloc
2018-03-01 5:59 [PATCH] driver core: Free memory obtained by kzalloc Arvind Yadav
@ 2018-03-01 10:54 ` Andy Shevchenko
2018-03-01 11:24 ` Arvind Yadav
0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2018-03-01 10:54 UTC (permalink / raw)
To: Arvind Yadav; +Cc: Greg Kroah-Hartman, Linux Kernel Mailing List
On Thu, Mar 1, 2018 at 7:59 AM, Arvind Yadav <arvind.yadav.cs@gmail.com> wrote:
> Here kfree() is taking NULL. So moving 'dev = NULL' after kfree().
Ouch! Does system_root_device_release() code ring a bell? How did you test this?
When you start eventually looking to the code?
NAK.
> diff --git a/drivers/base/bus.c b/drivers/base/bus.c
> index ef61833..ccb64a0 100644
> --- a/drivers/base/bus.c
> +++ b/drivers/base/bus.c
> @@ -1170,9 +1170,9 @@ static int subsys_register(struct bus_type *subsys,
>
> err_dev_reg:
> put_device(dev);
> - dev = NULL;
> err_name:
> kfree(dev);
> + dev = NULL;
> err_dev:
> bus_unregister(subsys);
> return err;
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] driver core: Free memory obtained by kzalloc
2018-03-01 10:54 ` Andy Shevchenko
@ 2018-03-01 11:24 ` Arvind Yadav
0 siblings, 0 replies; 3+ messages in thread
From: Arvind Yadav @ 2018-03-01 11:24 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Greg Kroah-Hartman, Linux Kernel Mailing List
Hi Andy,
sorry for noise.
On Thursday 01 March 2018 04:24 PM, Andy Shevchenko wrote:
> On Thu, Mar 1, 2018 at 7:59 AM, Arvind Yadav <arvind.yadav.cs@gmail.com> wrote:
>> Here kfree() is taking NULL. So moving 'dev = NULL' after kfree().
> Ouch! Does system_root_device_release() code ring a bell? How did you test this?
Yes, This is fine. put_device() will decrement a ref count.
So No need to call kfree() after put_device().
>
> When you start eventually looking to the code?
>
> NAK.
>
>> diff --git a/drivers/base/bus.c b/drivers/base/bus.c
>> index ef61833..ccb64a0 100644
>> --- a/drivers/base/bus.c
>> +++ b/drivers/base/bus.c
>> @@ -1170,9 +1170,9 @@ static int subsys_register(struct bus_type *subsys,
>>
>> err_dev_reg:
>> put_device(dev);
>> - dev = NULL;
>> err_name:
>> kfree(dev);
>> + dev = NULL;
>> err_dev:
>> bus_unregister(subsys);
>> return err;
Thanks for your review.
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-03-01 11:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-01 5:59 [PATCH] driver core: Free memory obtained by kzalloc Arvind Yadav
2018-03-01 10:54 ` Andy Shevchenko
2018-03-01 11:24 ` Arvind Yadav
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.