mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* check device_create_file() return code in usb_create_sysfs_intf_files()
@ 2011-03-24 14:31 Sergey Senozhatsky
  2011-03-24 14:42 ` Michal Nazarewicz
  2011-03-24 14:55 ` Alan Stern
  0 siblings, 2 replies; 6+ messages in thread
From: Sergey Senozhatsky @ 2011-03-24 14:31 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Alan Stern, Chris Wright, linux-usb, linux-kernel

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)


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-03-24 15:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-24 14:31 check device_create_file() return code in usb_create_sysfs_intf_files() Sergey Senozhatsky
2011-03-24 14:42 ` Michal Nazarewicz
2011-03-24 14:56   ` Sergey Senozhatsky
2011-03-24 14:58     ` Michal Nazarewicz
2011-03-24 14:55 ` Alan Stern
2011-03-24 15:05   ` Sergey Senozhatsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®