aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/usb/usbip/stub_dev.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/drivers/usb/usbip/stub_dev.c b/drivers/usb/usbip/stub_dev.c
index d094c96643d2..7931e6cecc70 100644
--- a/drivers/usb/usbip/stub_dev.c
+++ b/drivers/usb/usbip/stub_dev.c
@@ -326,14 +326,17 @@ static int stub_probe(struct usb_device *udev)
326 * See driver_probe_device() in driver/base/dd.c 326 * See driver_probe_device() in driver/base/dd.c
327 */ 327 */
328 rc = -ENODEV; 328 rc = -ENODEV;
329 goto sdev_free; 329 if (!busid_priv)
330 goto sdev_free;
331
332 goto call_put_busid_priv;
330 } 333 }
331 334
332 if (udev->descriptor.bDeviceClass == USB_CLASS_HUB) { 335 if (udev->descriptor.bDeviceClass == USB_CLASS_HUB) {
333 dev_dbg(&udev->dev, "%s is a usb hub device... skip!\n", 336 dev_dbg(&udev->dev, "%s is a usb hub device... skip!\n",
334 udev_busid); 337 udev_busid);
335 rc = -ENODEV; 338 rc = -ENODEV;
336 goto sdev_free; 339 goto call_put_busid_priv;
337 } 340 }
338 341
339 if (!strcmp(udev->bus->bus_name, "vhci_hcd")) { 342 if (!strcmp(udev->bus->bus_name, "vhci_hcd")) {
@@ -342,7 +345,7 @@ static int stub_probe(struct usb_device *udev)
342 udev_busid); 345 udev_busid);
343 346
344 rc = -ENODEV; 347 rc = -ENODEV;
345 goto sdev_free; 348 goto call_put_busid_priv;
346 } 349 }
347 350
348 351
@@ -361,6 +364,9 @@ static int stub_probe(struct usb_device *udev)
361 save_status = busid_priv->status; 364 save_status = busid_priv->status;
362 busid_priv->status = STUB_BUSID_ALLOC; 365 busid_priv->status = STUB_BUSID_ALLOC;
363 366
367 /* release the busid_lock */
368 put_busid_priv(busid_priv);
369
364 /* 370 /*
365 * Claim this hub port. 371 * Claim this hub port.
366 * It doesn't matter what value we pass as owner 372 * It doesn't matter what value we pass as owner
@@ -373,9 +379,6 @@ static int stub_probe(struct usb_device *udev)
373 goto err_port; 379 goto err_port;
374 } 380 }
375 381
376 /* release the busid_lock */
377 put_busid_priv(busid_priv);
378
379 rc = stub_add_files(&udev->dev); 382 rc = stub_add_files(&udev->dev);
380 if (rc) { 383 if (rc) {
381 dev_err(&udev->dev, "stub_add_files for %s\n", udev_busid); 384 dev_err(&udev->dev, "stub_add_files for %s\n", udev_busid);
@@ -395,11 +398,17 @@ err_port:
395 spin_lock(&busid_priv->busid_lock); 398 spin_lock(&busid_priv->busid_lock);
396 busid_priv->sdev = NULL; 399 busid_priv->sdev = NULL;
397 busid_priv->status = save_status; 400 busid_priv->status = save_status;
398sdev_free: 401 spin_unlock(&busid_priv->busid_lock);
399 stub_device_free(sdev); 402 /* lock is released - go to free */
403 goto sdev_free;
404
405call_put_busid_priv:
400 /* release the busid_lock */ 406 /* release the busid_lock */
401 put_busid_priv(busid_priv); 407 put_busid_priv(busid_priv);
402 408
409sdev_free:
410 stub_device_free(sdev);
411
403 return rc; 412 return rc;
404} 413}
405 414
@@ -435,7 +444,9 @@ static void stub_disconnect(struct usb_device *udev)
435 /* get stub_device */ 444 /* get stub_device */
436 if (!sdev) { 445 if (!sdev) {
437 dev_err(&udev->dev, "could not get device"); 446 dev_err(&udev->dev, "could not get device");
438 goto call_put_busid_priv; 447 /* release busid_lock */
448 put_busid_priv(busid_priv);
449 return;
439 } 450 }
440 451
441 dev_set_drvdata(&udev->dev, NULL); 452 dev_set_drvdata(&udev->dev, NULL);
@@ -465,7 +476,7 @@ static void stub_disconnect(struct usb_device *udev)
465 if (!busid_priv->shutdown_busid) 476 if (!busid_priv->shutdown_busid)
466 busid_priv->shutdown_busid = 1; 477 busid_priv->shutdown_busid = 1;
467 /* release busid_lock */ 478 /* release busid_lock */
468 put_busid_priv(busid_priv); 479 spin_unlock(&busid_priv->busid_lock);
469 480
470 /* shutdown the current connection */ 481 /* shutdown the current connection */
471 shutdown_busid(busid_priv); 482 shutdown_busid(busid_priv);
@@ -480,10 +491,9 @@ static void stub_disconnect(struct usb_device *udev)
480 491
481 if (busid_priv->status == STUB_BUSID_ALLOC) 492 if (busid_priv->status == STUB_BUSID_ALLOC)
482 busid_priv->status = STUB_BUSID_ADDED; 493 busid_priv->status = STUB_BUSID_ADDED;
483
484call_put_busid_priv:
485 /* release busid_lock */ 494 /* release busid_lock */
486 put_busid_priv(busid_priv); 495 spin_unlock(&busid_priv->busid_lock);
496 return;
487} 497}
488 498
489#ifdef CONFIG_PM 499#ifdef CONFIG_PM