From: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
To: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Alan Stern <stern@rowland.harvard.edu>,
Chris Wright <chrisw@sous-sol.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: check device_create_file() return code in usb_create_sysfs_intf_files()
Date: Thu, 24 Mar 2011 16:31:16 +0200 [thread overview]
Message-ID: <20110324143116.GA8200@swordfish.minsk.epam.com> (raw)
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)
next reply other threads:[~2011-03-24 14:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-24 14:31 Sergey Senozhatsky [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110324143116.GA8200@swordfish.minsk.epam.com \
--to=sergey.senozhatsky@gmail.com \
--cc=chrisw@sous-sol.org \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®