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

usbcore: fix endpoint device creation

This patch (as800) straightens out the USB endpoint class device
creation routine, fixing a refcount bug in the process.
Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent c40fd5ea
...@@ -223,7 +223,7 @@ int usb_create_ep_files(struct device *parent, ...@@ -223,7 +223,7 @@ int usb_create_ep_files(struct device *parent,
ep_dev = kzalloc(sizeof(*ep_dev), GFP_KERNEL); ep_dev = kzalloc(sizeof(*ep_dev), GFP_KERNEL);
if (!ep_dev) { if (!ep_dev) {
retval = -ENOMEM; retval = -ENOMEM;
goto exit; goto error_alloc;
} }
/* fun calculation to determine the minor of this endpoint */ /* fun calculation to determine the minor of this endpoint */
...@@ -241,33 +241,31 @@ int usb_create_ep_files(struct device *parent, ...@@ -241,33 +241,31 @@ int usb_create_ep_files(struct device *parent,
retval = device_register(&ep_dev->dev); retval = device_register(&ep_dev->dev);
if (retval) if (retval)
goto error; goto error_register;
retval = sysfs_create_group(&ep_dev->dev.kobj, &ep_dev_attr_grp); retval = sysfs_create_group(&ep_dev->dev.kobj, &ep_dev_attr_grp);
if (retval) if (retval)
goto error_group; goto error_group;
endpoint->ep_dev = ep_dev;
/* create the symlink to the old-style "ep_XX" directory */ /* create the symlink to the old-style "ep_XX" directory */
sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress); sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress);
retval = sysfs_create_link(&parent->kobj, retval = sysfs_create_link(&parent->kobj, &ep_dev->dev.kobj, name);
&endpoint->ep_dev->dev.kobj, name);
if (retval) if (retval)
goto error_link; goto error_link;
exit: endpoint->ep_dev = ep_dev;
return retval; return retval;
error_link: error_link:
sysfs_remove_group(&ep_dev->dev.kobj, &ep_dev_attr_grp); sysfs_remove_group(&ep_dev->dev.kobj, &ep_dev_attr_grp);
error_group: error_group:
device_unregister(&ep_dev->dev); device_unregister(&ep_dev->dev);
endpoint->ep_dev = NULL;
destroy_endpoint_class(); destroy_endpoint_class();
return retval; return retval;
error:
error_register:
kfree(ep_dev); kfree(ep_dev);
error_alloc:
destroy_endpoint_class(); destroy_endpoint_class();
exit:
return retval; return retval;
} }
......
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