* [PATCH] usb: core: endpoint: Fix error path
@ 2010-10-02 6:48 Rahul Ruikar
2010-10-02 7:45 ` Ming Lei
0 siblings, 1 reply; 10+ messages in thread
From: Rahul Ruikar @ 2010-10-02 6:48 UTC (permalink / raw)
To: Greg Kroah-Hartman, Tejun Heo, asanchez, rjw
Cc: linux-usb, linux-kernel, Rahul Ruikar
In function usb_create_ep_devs()
call put_device() when device_register() fails.
Signed-off-by: Rahul Ruikar <rahul.ruikar@gmail.com>
---
drivers/usb/core/endpoint.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c
index 3788e73..cab126d 100644
--- a/drivers/usb/core/endpoint.c
+++ b/drivers/usb/core/endpoint.c
@@ -195,8 +195,10 @@ int usb_create_ep_devs(struct device *parent,
device_enable_async_suspend(&ep_dev->dev);
retval = device_register(&ep_dev->dev);
- if (retval)
+ if (retval) {
+ put_device(&ep_dev->dev);
goto error_register;
+ }
endpoint->ep_dev = ep_dev;
return retval;
--
1.7.2.3
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH] usb: core: endpoint: Fix error path
2010-10-02 6:48 [PATCH] usb: core: endpoint: Fix error path Rahul Ruikar
@ 2010-10-02 7:45 ` Ming Lei
2010-10-02 8:46 ` Rahul Ruikar
0 siblings, 1 reply; 10+ messages in thread
From: Ming Lei @ 2010-10-02 7:45 UTC (permalink / raw)
To: Rahul Ruikar
Cc: Greg Kroah-Hartman, Tejun Heo, asanchez, rjw, linux-usb,
linux-kernel
2010/10/2 Rahul Ruikar <rahul.ruikar@gmail.com>:
> In function usb_create_ep_devs()
> call put_device() when device_register() fails.
>
> Signed-off-by: Rahul Ruikar <rahul.ruikar@gmail.com>
> ---
> drivers/usb/core/endpoint.c | 4 +++-
> 1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c
> index 3788e73..cab126d 100644
> --- a/drivers/usb/core/endpoint.c
> +++ b/drivers/usb/core/endpoint.c
> @@ -195,8 +195,10 @@ int usb_create_ep_devs(struct device *parent,
> device_enable_async_suspend(&ep_dev->dev);
>
> retval = device_register(&ep_dev->dev);
> - if (retval)
> + if (retval) {
> + put_device(&ep_dev->dev);
> goto error_register;
> + }
>
> endpoint->ep_dev = ep_dev;
> return retval;
> --
You should replace kfree(ep_dev) with put_device(&ep_dev->dev),
otherwise double free will be triggered.
So you need to revise the patch...
--
Lei Ming
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH] usb: core: endpoint: Fix error path
2010-10-02 7:45 ` Ming Lei
@ 2010-10-02 8:46 ` Rahul Ruikar
2010-10-02 9:58 ` Ming Lei
2010-10-06 20:23 ` Greg KH
0 siblings, 2 replies; 10+ messages in thread
From: Rahul Ruikar @ 2010-10-02 8:46 UTC (permalink / raw)
To: Ming Lei, Greg Kroah-Hartman, Tejun Heo, asanchez, rjw
Cc: linux-usb, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1209 bytes --]
revised patch attached.
Thanks
- Rahul Ruikar
On 2 October 2010 13:15, Ming Lei <tom.leiming@gmail.com> wrote:
> 2010/10/2 Rahul Ruikar <rahul.ruikar@gmail.com>:
>> In function usb_create_ep_devs()
>> call put_device() when device_register() fails.
>>
>> Signed-off-by: Rahul Ruikar <rahul.ruikar@gmail.com>
>> ---
>> drivers/usb/core/endpoint.c | 4 +++-
>> 1 files changed, 3 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c
>> index 3788e73..cab126d 100644
>> --- a/drivers/usb/core/endpoint.c
>> +++ b/drivers/usb/core/endpoint.c
>> @@ -195,8 +195,10 @@ int usb_create_ep_devs(struct device *parent,
>> device_enable_async_suspend(&ep_dev->dev);
>>
>> retval = device_register(&ep_dev->dev);
>> - if (retval)
>> + if (retval) {
>> + put_device(&ep_dev->dev);
>> goto error_register;
>> + }
>>
>> endpoint->ep_dev = ep_dev;
>> return retval;
>> --
>
> You should replace kfree(ep_dev) with put_device(&ep_dev->dev),
> otherwise double free will be triggered.
>
> So you need to revise the patch...
>
> --
> Lei Ming
>
[-- Attachment #2: 0001-usb-core-endpoint-Fix-error-path.patch --]
[-- Type: text/x-patch, Size: 791 bytes --]
From 0189060361c503a78ffb055f9c2ab50ac5a1a88e Mon Sep 17 00:00:00 2001
From: Rahul Ruikar <rahul.ruikar@gmail.com>
Date: Sat, 2 Oct 2010 14:09:39 +0530
Subject: [PATCH] usb: core: endpoint: Fix error path
In function usb_create_ep_devs()
call put_device() when device_register() fails.
Signed-off-by: Rahul Ruikar <rahul.ruikar@gmail.com>
---
drivers/usb/core/endpoint.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c
index 3788e73..9da2505 100644
--- a/drivers/usb/core/endpoint.c
+++ b/drivers/usb/core/endpoint.c
@@ -202,7 +202,7 @@ int usb_create_ep_devs(struct device *parent,
return retval;
error_register:
- kfree(ep_dev);
+ put_device(&ep_dev->dev);
exit:
return retval;
}
--
1.7.2.3
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH] usb: core: endpoint: Fix error path
2010-10-02 8:46 ` Rahul Ruikar
@ 2010-10-02 9:58 ` Ming Lei
2010-10-02 10:14 ` Rahul Ruikar
2010-10-06 20:23 ` Greg KH
1 sibling, 1 reply; 10+ messages in thread
From: Ming Lei @ 2010-10-02 9:58 UTC (permalink / raw)
To: Rahul Ruikar
Cc: Greg Kroah-Hartman, Tejun Heo, asanchez, rjw, linux-usb,
linux-kernel
2010/10/2 Rahul Ruikar <rahul.ruikar@gmail.com>:
> revised patch attached.
Acked-by: Ming Lei <tom.leiming@gmail.com>
--
Lei Ming
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] usb: core: endpoint: Fix error path
2010-10-02 9:58 ` Ming Lei
@ 2010-10-02 10:14 ` Rahul Ruikar
2010-10-02 10:28 ` Ming Lei
0 siblings, 1 reply; 10+ messages in thread
From: Rahul Ruikar @ 2010-10-02 10:14 UTC (permalink / raw)
To: Ming Lei
Cc: Greg Kroah-Hartman, Tejun Heo, asanchez, rjw, linux-usb,
linux-kernel
Thanks Ming.
I have certain doubts related to device_unregister()
In some of USB related code..
kfree() is called after device_unregister() ... device_unregister()
also internally calls put_device()... is that correct behavior or I'm
missing something here..
ex.
file : drivers/usb/gadget/fsl_udc_core.c
function : static int __init fsl_udc_probe(struct platform_device *pdev)
- Rahul Ruikar
On 2 October 2010 15:28, Ming Lei <tom.leiming@gmail.com> wrote:
> 2010/10/2 Rahul Ruikar <rahul.ruikar@gmail.com>:
>> revised patch attached.
>
> Acked-by: Ming Lei <tom.leiming@gmail.com>
>
> --
> Lei Ming
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] usb: core: endpoint: Fix error path
2010-10-02 10:14 ` Rahul Ruikar
@ 2010-10-02 10:28 ` Ming Lei
0 siblings, 0 replies; 10+ messages in thread
From: Ming Lei @ 2010-10-02 10:28 UTC (permalink / raw)
To: Rahul Ruikar
Cc: Greg Kroah-Hartman, Tejun Heo, asanchez, rjw, linux-usb,
linux-kernel
2010/10/2 Rahul Ruikar <rahul.ruikar@gmail.com>:
> Thanks Ming.
> I have certain doubts related to device_unregister()
>
> In some of USB related code..
> kfree() is called after device_unregister() ... device_unregister()
> also internally calls put_device()... is that correct behavior or I'm
> missing something here..
If no other external reference to device before put_device in device_unregister,
dev.release will be called from put_device to free something, which depends
on your implement for dev.release.
> ex.
> file : drivers/usb/gadget/fsl_udc_core.c
> function : static int __init fsl_udc_probe(struct platform_device *pdev)
Once reaches err_unregister, double free of udc_controller may be
triggered, so fix should be needed.
--
Lei Ming
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] usb: core: endpoint: Fix error path
2010-10-02 8:46 ` Rahul Ruikar
2010-10-02 9:58 ` Ming Lei
@ 2010-10-06 20:23 ` Greg KH
2010-10-07 4:03 ` Rahul Ruikar
1 sibling, 1 reply; 10+ messages in thread
From: Greg KH @ 2010-10-06 20:23 UTC (permalink / raw)
To: Rahul Ruikar
Cc: Ming Lei, Greg Kroah-Hartman, Tejun Heo, asanchez, rjw, linux-usb,
linux-kernel
On Sat, Oct 02, 2010 at 02:16:14PM +0530, Rahul Ruikar wrote:
> revised patch attached.
Please resend it in the proper format.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] usb: core: endpoint: Fix error path
2010-10-06 20:23 ` Greg KH
@ 2010-10-07 4:03 ` Rahul Ruikar
0 siblings, 0 replies; 10+ messages in thread
From: Rahul Ruikar @ 2010-10-07 4:03 UTC (permalink / raw)
To: Greg KH
Cc: Ming Lei, Greg Kroah-Hartman, Tejun Heo, asanchez, rjw, linux-usb,
linux-kernel
Sent in another mail now.
- Rahul Ruikar
On 7 October 2010 01:53, Greg KH <greg@kroah.com> wrote:
> On Sat, Oct 02, 2010 at 02:16:14PM +0530, Rahul Ruikar wrote:
>> revised patch attached.
>
> Please resend it in the proper format.
>
> thanks,
>
> greg k-h
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] usb: core: endpoint: Fix error path
@ 2010-10-07 4:01 Rahul Ruikar
2010-10-07 4:03 ` Rahul Ruikar
0 siblings, 1 reply; 10+ messages in thread
From: Rahul Ruikar @ 2010-10-07 4:01 UTC (permalink / raw)
To: Greg Kroah-Hartman, Tejun Heo, asanchez, rjw, csanchez
Cc: linux-usb, linux-kernel, Rahul Ruikar
In function usb_create_ep_devs()
call put_device() when device_register() fails.
Signed-off-by: Rahul Ruikar <rahul.ruikar@gmail.com>
---
drivers/usb/core/endpoint.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c
index 3788e73..9da2505 100644
--- a/drivers/usb/core/endpoint.c
+++ b/drivers/usb/core/endpoint.c
@@ -202,7 +202,7 @@ int usb_create_ep_devs(struct device *parent,
return retval;
error_register:
- kfree(ep_dev);
+ put_device(&ep_dev->dev);
exit:
return retval;
}
--
1.7.2.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] usb: core: endpoint: Fix error path
2010-10-07 4:01 Rahul Ruikar
@ 2010-10-07 4:03 ` Rahul Ruikar
0 siblings, 0 replies; 10+ messages in thread
From: Rahul Ruikar @ 2010-10-07 4:03 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: linux-usb, linux-kernel, Rahul Ruikar, Tejun Heo, asanchez, rjw,
csanchez
Greg,
Kindly include this patch.
- Rahul Ruikar
On 7 October 2010 09:31, Rahul Ruikar <rahul.ruikar@gmail.com> wrote:
> In function usb_create_ep_devs()
> call put_device() when device_register() fails.
>
> Signed-off-by: Rahul Ruikar <rahul.ruikar@gmail.com>
> ---
> drivers/usb/core/endpoint.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c
> index 3788e73..9da2505 100644
> --- a/drivers/usb/core/endpoint.c
> +++ b/drivers/usb/core/endpoint.c
> @@ -202,7 +202,7 @@ int usb_create_ep_devs(struct device *parent,
> return retval;
>
> error_register:
> - kfree(ep_dev);
> + put_device(&ep_dev->dev);
> exit:
> return retval;
> }
> --
> 1.7.2.3
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2010-10-07 4:05 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-02 6:48 [PATCH] usb: core: endpoint: Fix error path Rahul Ruikar
2010-10-02 7:45 ` Ming Lei
2010-10-02 8:46 ` Rahul Ruikar
2010-10-02 9:58 ` Ming Lei
2010-10-02 10:14 ` Rahul Ruikar
2010-10-02 10:28 ` Ming Lei
2010-10-06 20:23 ` Greg KH
2010-10-07 4:03 ` Rahul Ruikar
-- strict thread matches above, loose matches on Subject: below --
2010-10-07 4:01 Rahul Ruikar
2010-10-07 4:03 ` Rahul Ruikar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox