From: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
To: Michal Nazarewicz <mina86@mina86.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>,
Alan Stern <stern@rowland.harvard.edu>,
Chris Wright <chrisw@sous-sol.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: check device_create_file() return code in usb_create_sysfs_intf_files()
Date: Thu, 24 Mar 2011 16:56:06 +0200 [thread overview]
Message-ID: <20110324145606.GB8200@swordfish.minsk.epam.com> (raw)
In-Reply-To: <op.vsuq5nez3l0zgt@mnazarewicz-glaptop>
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)
next prev parent reply other threads:[~2011-03-24 14:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-24 14:31 Sergey Senozhatsky
2011-03-24 14:42 ` Michal Nazarewicz
2011-03-24 14:56 ` Sergey Senozhatsky [this message]
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=20110324145606.GB8200@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=mina86@mina86.com \
--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®