lkml.org 
[lkml]   [2011]   [Mar]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: check device_create_file() return code in usb_create_sysfs_intf_files()
On (03/24/11 15:42), Michal Nazarewicz wrote:
> >@@ -856,8 +856,10 @@ int usb_create_sysfs_intf_files(struct
> >usb_interface *intf)
> > alt->string = usb_cache_string(udev, alt->desc.iInterface);
> > if (alt->string)
> > retval = device_create_file(&intf->dev, &dev_attr_interface);
> >- intf->sysfs_files_created = 1;
> >- return 0;
> >+ if (retval == 0)
> >+ intf->sysfs_files_created = 1;
> >+
> >+ return retval;
> > }
>
> retval may be uninitialised. You need to zero it at the beginning of the
> function (or somewhere).
>

Oops... Yes, indeed. Thanks.

---

drivers/usb/core/sysfs.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index 6781c36..d03c630 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -846,7 +846,7 @@ int usb_create_sysfs_intf_files(struct usb_interface *intf)
{
struct usb_device *udev = interface_to_usbdev(intf);
struct usb_host_interface *alt = intf->cur_altsetting;
- int retval;
+ int retval = -1;

if (intf->sysfs_files_created || intf->unregistering)
return 0;
@@ -856,8 +856,10 @@ int usb_create_sysfs_intf_files(struct usb_interface *intf)
alt->string = usb_cache_string(udev, alt->desc.iInterface);
if (alt->string)
retval = device_create_file(&intf->dev, &dev_attr_interface);
- intf->sysfs_files_created = 1;
- return 0;
+ if (retval == 0)
+ intf->sysfs_files_created = 1;
+
+ return retval;
}

void usb_remove_sysfs_intf_files(struct usb_interface *intf)


\
 
 \ /
  Last update: 2011-03-24 15:55    [W:1.069 / U:0.184 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site