diff options
Diffstat (limited to 'drivers/usb/usbip/stub_dev.c')
-rw-r--r-- | drivers/usb/usbip/stub_dev.c | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/drivers/usb/usbip/stub_dev.c b/drivers/usb/usbip/stub_dev.c index dd8ef36ab10e..c0d6ff1baa72 100644 --- a/drivers/usb/usbip/stub_dev.c +++ b/drivers/usb/usbip/stub_dev.c | |||
@@ -300,9 +300,9 @@ static int stub_probe(struct usb_device *udev) | |||
300 | struct stub_device *sdev = NULL; | 300 | struct stub_device *sdev = NULL; |
301 | const char *udev_busid = dev_name(&udev->dev); | 301 | const char *udev_busid = dev_name(&udev->dev); |
302 | struct bus_id_priv *busid_priv; | 302 | struct bus_id_priv *busid_priv; |
303 | int rc; | 303 | int rc = 0; |
304 | 304 | ||
305 | dev_dbg(&udev->dev, "Enter\n"); | 305 | dev_dbg(&udev->dev, "Enter probe\n"); |
306 | 306 | ||
307 | /* check we should claim or not by busid_table */ | 307 | /* check we should claim or not by busid_table */ |
308 | busid_priv = get_busid_priv(udev_busid); | 308 | busid_priv = get_busid_priv(udev_busid); |
@@ -317,13 +317,15 @@ static int stub_probe(struct usb_device *udev) | |||
317 | * other matched drivers by the driver core. | 317 | * other matched drivers by the driver core. |
318 | * See driver_probe_device() in driver/base/dd.c | 318 | * See driver_probe_device() in driver/base/dd.c |
319 | */ | 319 | */ |
320 | return -ENODEV; | 320 | rc = -ENODEV; |
321 | goto call_put_busid_priv; | ||
321 | } | 322 | } |
322 | 323 | ||
323 | if (udev->descriptor.bDeviceClass == USB_CLASS_HUB) { | 324 | if (udev->descriptor.bDeviceClass == USB_CLASS_HUB) { |
324 | dev_dbg(&udev->dev, "%s is a usb hub device... skip!\n", | 325 | dev_dbg(&udev->dev, "%s is a usb hub device... skip!\n", |
325 | udev_busid); | 326 | udev_busid); |
326 | return -ENODEV; | 327 | rc = -ENODEV; |
328 | goto call_put_busid_priv; | ||
327 | } | 329 | } |
328 | 330 | ||
329 | if (!strcmp(udev->bus->bus_name, "vhci_hcd")) { | 331 | if (!strcmp(udev->bus->bus_name, "vhci_hcd")) { |
@@ -331,13 +333,16 @@ static int stub_probe(struct usb_device *udev) | |||
331 | "%s is attached on vhci_hcd... skip!\n", | 333 | "%s is attached on vhci_hcd... skip!\n", |
332 | udev_busid); | 334 | udev_busid); |
333 | 335 | ||
334 | return -ENODEV; | 336 | rc = -ENODEV; |
337 | goto call_put_busid_priv; | ||
335 | } | 338 | } |
336 | 339 | ||
337 | /* ok, this is my device */ | 340 | /* ok, this is my device */ |
338 | sdev = stub_device_alloc(udev); | 341 | sdev = stub_device_alloc(udev); |
339 | if (!sdev) | 342 | if (!sdev) { |
340 | return -ENOMEM; | 343 | rc = -ENOMEM; |
344 | goto call_put_busid_priv; | ||
345 | } | ||
341 | 346 | ||
342 | dev_info(&udev->dev, | 347 | dev_info(&udev->dev, |
343 | "usbip-host: register new device (bus %u dev %u)\n", | 348 | "usbip-host: register new device (bus %u dev %u)\n", |
@@ -369,7 +374,9 @@ static int stub_probe(struct usb_device *udev) | |||
369 | } | 374 | } |
370 | busid_priv->status = STUB_BUSID_ALLOC; | 375 | busid_priv->status = STUB_BUSID_ALLOC; |
371 | 376 | ||
372 | return 0; | 377 | rc = 0; |
378 | goto call_put_busid_priv; | ||
379 | |||
373 | err_files: | 380 | err_files: |
374 | usb_hub_release_port(udev->parent, udev->portnum, | 381 | usb_hub_release_port(udev->parent, udev->portnum, |
375 | (struct usb_dev_state *) udev); | 382 | (struct usb_dev_state *) udev); |
@@ -379,6 +386,9 @@ err_port: | |||
379 | 386 | ||
380 | busid_priv->sdev = NULL; | 387 | busid_priv->sdev = NULL; |
381 | stub_device_free(sdev); | 388 | stub_device_free(sdev); |
389 | |||
390 | call_put_busid_priv: | ||
391 | put_busid_priv(busid_priv); | ||
382 | return rc; | 392 | return rc; |
383 | } | 393 | } |
384 | 394 | ||
@@ -404,7 +414,7 @@ static void stub_disconnect(struct usb_device *udev) | |||
404 | struct bus_id_priv *busid_priv; | 414 | struct bus_id_priv *busid_priv; |
405 | int rc; | 415 | int rc; |
406 | 416 | ||
407 | dev_dbg(&udev->dev, "Enter\n"); | 417 | dev_dbg(&udev->dev, "Enter disconnect\n"); |
408 | 418 | ||
409 | busid_priv = get_busid_priv(udev_busid); | 419 | busid_priv = get_busid_priv(udev_busid); |
410 | if (!busid_priv) { | 420 | if (!busid_priv) { |
@@ -417,7 +427,7 @@ static void stub_disconnect(struct usb_device *udev) | |||
417 | /* get stub_device */ | 427 | /* get stub_device */ |
418 | if (!sdev) { | 428 | if (!sdev) { |
419 | dev_err(&udev->dev, "could not get device"); | 429 | dev_err(&udev->dev, "could not get device"); |
420 | return; | 430 | goto call_put_busid_priv; |
421 | } | 431 | } |
422 | 432 | ||
423 | dev_set_drvdata(&udev->dev, NULL); | 433 | dev_set_drvdata(&udev->dev, NULL); |
@@ -432,12 +442,12 @@ static void stub_disconnect(struct usb_device *udev) | |||
432 | (struct usb_dev_state *) udev); | 442 | (struct usb_dev_state *) udev); |
433 | if (rc) { | 443 | if (rc) { |
434 | dev_dbg(&udev->dev, "unable to release port\n"); | 444 | dev_dbg(&udev->dev, "unable to release port\n"); |
435 | return; | 445 | goto call_put_busid_priv; |
436 | } | 446 | } |
437 | 447 | ||
438 | /* If usb reset is called from event handler */ | 448 | /* If usb reset is called from event handler */ |
439 | if (usbip_in_eh(current)) | 449 | if (usbip_in_eh(current)) |
440 | return; | 450 | goto call_put_busid_priv; |
441 | 451 | ||
442 | /* shutdown the current connection */ | 452 | /* shutdown the current connection */ |
443 | shutdown_busid(busid_priv); | 453 | shutdown_busid(busid_priv); |
@@ -448,12 +458,11 @@ static void stub_disconnect(struct usb_device *udev) | |||
448 | busid_priv->sdev = NULL; | 458 | busid_priv->sdev = NULL; |
449 | stub_device_free(sdev); | 459 | stub_device_free(sdev); |
450 | 460 | ||
451 | if (busid_priv->status == STUB_BUSID_ALLOC) { | 461 | if (busid_priv->status == STUB_BUSID_ALLOC) |
452 | busid_priv->status = STUB_BUSID_ADDED; | 462 | busid_priv->status = STUB_BUSID_ADDED; |
453 | } else { | 463 | |
454 | busid_priv->status = STUB_BUSID_OTHER; | 464 | call_put_busid_priv: |
455 | del_match_busid((char *)udev_busid); | 465 | put_busid_priv(busid_priv); |
456 | } | ||
457 | } | 466 | } |
458 | 467 | ||
459 | #ifdef CONFIG_PM | 468 | #ifdef CONFIG_PM |