diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2006-10-10 11:56:26 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-10-17 17:46:32 -0400 |
commit | d5477c11111467e19787f00d3cab20fb48c2699e (patch) | |
tree | 58716db7e697cdacec1895fc9803604eddfc775c | |
parent | c40fd5ea565587c05b0e2c49c02cad2c35fd85c6 (diff) |
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: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/usb/core/endpoint.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c index 40ba76a17571..3b2d137912be 100644 --- a/drivers/usb/core/endpoint.c +++ b/drivers/usb/core/endpoint.c | |||
@@ -223,7 +223,7 @@ int usb_create_ep_files(struct device *parent, | |||
223 | ep_dev = kzalloc(sizeof(*ep_dev), GFP_KERNEL); | 223 | ep_dev = kzalloc(sizeof(*ep_dev), GFP_KERNEL); |
224 | if (!ep_dev) { | 224 | if (!ep_dev) { |
225 | retval = -ENOMEM; | 225 | retval = -ENOMEM; |
226 | goto exit; | 226 | goto error_alloc; |
227 | } | 227 | } |
228 | 228 | ||
229 | /* fun calculation to determine the minor of this endpoint */ | 229 | /* fun calculation to determine the minor of this endpoint */ |
@@ -241,33 +241,31 @@ int usb_create_ep_files(struct device *parent, | |||
241 | 241 | ||
242 | retval = device_register(&ep_dev->dev); | 242 | retval = device_register(&ep_dev->dev); |
243 | if (retval) | 243 | if (retval) |
244 | goto error; | 244 | goto error_register; |
245 | retval = sysfs_create_group(&ep_dev->dev.kobj, &ep_dev_attr_grp); | 245 | retval = sysfs_create_group(&ep_dev->dev.kobj, &ep_dev_attr_grp); |
246 | if (retval) | 246 | if (retval) |
247 | goto error_group; | 247 | goto error_group; |
248 | 248 | ||
249 | endpoint->ep_dev = ep_dev; | ||
250 | |||
251 | /* create the symlink to the old-style "ep_XX" directory */ | 249 | /* create the symlink to the old-style "ep_XX" directory */ |
252 | sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress); | 250 | sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress); |
253 | retval = sysfs_create_link(&parent->kobj, | 251 | retval = sysfs_create_link(&parent->kobj, &ep_dev->dev.kobj, name); |
254 | &endpoint->ep_dev->dev.kobj, name); | ||
255 | if (retval) | 252 | if (retval) |
256 | goto error_link; | 253 | goto error_link; |
257 | exit: | 254 | endpoint->ep_dev = ep_dev; |
258 | return retval; | 255 | return retval; |
259 | 256 | ||
260 | error_link: | 257 | error_link: |
261 | sysfs_remove_group(&ep_dev->dev.kobj, &ep_dev_attr_grp); | 258 | sysfs_remove_group(&ep_dev->dev.kobj, &ep_dev_attr_grp); |
262 | |||
263 | error_group: | 259 | error_group: |
264 | device_unregister(&ep_dev->dev); | 260 | device_unregister(&ep_dev->dev); |
265 | endpoint->ep_dev = NULL; | ||
266 | destroy_endpoint_class(); | 261 | destroy_endpoint_class(); |
267 | return retval; | 262 | return retval; |
268 | error: | 263 | |
264 | error_register: | ||
269 | kfree(ep_dev); | 265 | kfree(ep_dev); |
266 | error_alloc: | ||
270 | destroy_endpoint_class(); | 267 | destroy_endpoint_class(); |
268 | exit: | ||
271 | return retval; | 269 | return retval; |
272 | } | 270 | } |
273 | 271 | ||