check device_create_file() return code inusb_create_sysfs_intf_files()
From: Sergey Senozhatsky
Date: Thu Mar 24 2011 - 10:27:23 EST
Hello,
I just noticed that usb_create_sysfs_intf_files() ignores device_create_file()
return code and sets intf->sysfs_files_created to 1, even if sysfs_add_file_mode()
returned -ENOMEM (or later sysfs_add_one() returned -EEXIST).
Shouldn't we check retval for 0 before setting intf->sysfs_files_created?
---
drivers/usb/core/sysfs.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index 6781c36..5a02524 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -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)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/