Re: [PATCH] usb: core: endpoint: Fix error path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



revised patch attached.

Thanks
- Rahul Ruikar





On 2 October 2010 13:15, Ming Lei <tom.leiming@xxxxxxxxx> wrote:
> 2010/10/2 Rahul Ruikar <rahul.ruikar@xxxxxxxxx>:
>> In function usb_create_ep_devs()
>> call put_device() when device_register() fails.
>>
>> Signed-off-by: Rahul Ruikar <rahul.ruikar@xxxxxxxxx>
>> ---
>>  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
>
From 0189060361c503a78ffb055f9c2ab50ac5a1a88e Mon Sep 17 00:00:00 2001
From: Rahul Ruikar <rahul.ruikar@xxxxxxxxx>
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@xxxxxxxxx>
---
 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


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux