aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorAlexey Khoroshilov <khoroshilov@ispras.ru>2014-11-28 17:29:10 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-12-02 19:15:02 -0500
commit3ff67445750a84de67faaf52c6e1895cb09f2c56 (patch)
tree2a50f3fd3401948f0bcfe8ba1fa468bd2c828074 /drivers/usb
parent016040268ccafaa7ad74ef88708d54fedeb87072 (diff)
usbip: fix error handling in stub_probe()
If usb_hub_claim_port() fails, no resources are deallocated and if stub_add_files() fails, port is not released. The patch fixes these issues and rearranges error handling code. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru> Acked-by: Valentina Manea <valentina.manea.m@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/usbip/stub_dev.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/drivers/usb/usbip/stub_dev.c b/drivers/usb/usbip/stub_dev.c
index fac20e0434c0..a3ec49bdc1e6 100644
--- a/drivers/usb/usbip/stub_dev.c
+++ b/drivers/usb/usbip/stub_dev.c
@@ -311,7 +311,6 @@ static int stub_probe(struct usb_device *udev)
311{ 311{
312 struct stub_device *sdev = NULL; 312 struct stub_device *sdev = NULL;
313 const char *udev_busid = dev_name(&udev->dev); 313 const char *udev_busid = dev_name(&udev->dev);
314 int err = 0;
315 struct bus_id_priv *busid_priv; 314 struct bus_id_priv *busid_priv;
316 int rc; 315 int rc;
317 316
@@ -372,23 +371,28 @@ static int stub_probe(struct usb_device *udev)
372 (struct usb_dev_state *) udev); 371 (struct usb_dev_state *) udev);
373 if (rc) { 372 if (rc) {
374 dev_dbg(&udev->dev, "unable to claim port\n"); 373 dev_dbg(&udev->dev, "unable to claim port\n");
375 return rc; 374 goto err_port;
376 } 375 }
377 376
378 err = stub_add_files(&udev->dev); 377 rc = stub_add_files(&udev->dev);
379 if (err) { 378 if (rc) {
380 dev_err(&udev->dev, "stub_add_files for %s\n", udev_busid); 379 dev_err(&udev->dev, "stub_add_files for %s\n", udev_busid);
381 dev_set_drvdata(&udev->dev, NULL); 380 goto err_files;
382 usb_put_dev(udev);
383 kthread_stop_put(sdev->ud.eh);
384
385 busid_priv->sdev = NULL;
386 stub_device_free(sdev);
387 return err;
388 } 381 }
389 busid_priv->status = STUB_BUSID_ALLOC; 382 busid_priv->status = STUB_BUSID_ALLOC;
390 383
391 return 0; 384 return 0;
385err_files:
386 usb_hub_release_port(udev->parent, udev->portnum,
387 (struct usb_dev_state *) udev);
388err_port:
389 dev_set_drvdata(&udev->dev, NULL);
390 usb_put_dev(udev);
391 kthread_stop_put(sdev->ud.eh);
392
393 busid_priv->sdev = NULL;
394 stub_device_free(sdev);
395 return rc;
392} 396}
393 397
394static void shutdown_busid(struct bus_id_priv *busid_priv) 398static void shutdown_busid(struct bus_id_priv *busid_priv)