Commit feb4edac authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman

[PATCH] USB: Fix NULL-pointer bug in dummy_hcd

This patch fixes a NULL-pointer-dereference bug in the dummy_hcd driver.
It also makes the code slightly more elegant and removes an unnecessary
buffer-overflow test.  Unfortunately it's still a little bit racy, but
this is a fault it shares with other gadget controller drivers, like
net2280.
Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 99202312
......@@ -596,14 +596,13 @@ static const struct usb_gadget_ops dummy_ops = {
/* "function" sysfs attribute */
static ssize_t
show_function (struct device *_dev, char *buf)
show_function (struct device *dev, char *buf)
{
struct dummy *dum = the_controller;
struct dummy *dum = gadget_dev_to_dummy (dev);
if (!dum->driver->function
|| strlen (dum->driver->function) > PAGE_SIZE)
if (!dum->driver || !dum->driver->function)
return 0;
return snprintf (buf, PAGE_SIZE, "%s\n", dum->driver->function);
return scnprintf (buf, PAGE_SIZE, "%s\n", dum->driver->function);
}
DEVICE_ATTR (function, S_IRUGO, show_function, NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment