diff options
author | Alexey Khoroshilov <khoroshilov@ispras.ru> | 2015-03-27 18:39:09 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-04-02 22:55:20 -0400 |
commit | afd270d1a45043cef14341bcceff62ed50e8dc9a (patch) | |
tree | 1d4eb5414cdb217841453d083d4c48f45fd136d8 /drivers/media | |
parent | cc7d2dfb75b3ac0f248801ceed65f69465eb0389 (diff) |
[media] usbvision: fix leak of usb_dev on failure paths in usbvision_probe()
There is no usb_put_dev() on failure paths in usbvision_probe().
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/usb/usbvision/usbvision-video.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/drivers/media/usb/usbvision/usbvision-video.c b/drivers/media/usb/usbvision/usbvision-video.c index 2579c874b83b..12b403e78d52 100644 --- a/drivers/media/usb/usbvision/usbvision-video.c +++ b/drivers/media/usb/usbvision/usbvision-video.c | |||
@@ -1507,7 +1507,7 @@ static int usbvision_probe(struct usb_interface *intf, | |||
1507 | const struct usb_host_interface *interface; | 1507 | const struct usb_host_interface *interface; |
1508 | struct usb_usbvision *usbvision = NULL; | 1508 | struct usb_usbvision *usbvision = NULL; |
1509 | const struct usb_endpoint_descriptor *endpoint; | 1509 | const struct usb_endpoint_descriptor *endpoint; |
1510 | int model, i; | 1510 | int model, i, ret; |
1511 | 1511 | ||
1512 | PDEBUG(DBG_PROBE, "VID=%#04x, PID=%#04x, ifnum=%u", | 1512 | PDEBUG(DBG_PROBE, "VID=%#04x, PID=%#04x, ifnum=%u", |
1513 | dev->descriptor.idVendor, | 1513 | dev->descriptor.idVendor, |
@@ -1516,7 +1516,8 @@ static int usbvision_probe(struct usb_interface *intf, | |||
1516 | model = devid->driver_info; | 1516 | model = devid->driver_info; |
1517 | if (model < 0 || model >= usbvision_device_data_size) { | 1517 | if (model < 0 || model >= usbvision_device_data_size) { |
1518 | PDEBUG(DBG_PROBE, "model out of bounds %d", model); | 1518 | PDEBUG(DBG_PROBE, "model out of bounds %d", model); |
1519 | return -ENODEV; | 1519 | ret = -ENODEV; |
1520 | goto err_usb; | ||
1520 | } | 1521 | } |
1521 | printk(KERN_INFO "%s: %s found\n", __func__, | 1522 | printk(KERN_INFO "%s: %s found\n", __func__, |
1522 | usbvision_device_data[model].model_string); | 1523 | usbvision_device_data[model].model_string); |
@@ -1531,18 +1532,21 @@ static int usbvision_probe(struct usb_interface *intf, | |||
1531 | __func__, ifnum); | 1532 | __func__, ifnum); |
1532 | dev_err(&intf->dev, "%s: Endpoint attributes %d", | 1533 | dev_err(&intf->dev, "%s: Endpoint attributes %d", |
1533 | __func__, endpoint->bmAttributes); | 1534 | __func__, endpoint->bmAttributes); |
1534 | return -ENODEV; | 1535 | ret = -ENODEV; |
1536 | goto err_usb; | ||
1535 | } | 1537 | } |
1536 | if (usb_endpoint_dir_out(endpoint)) { | 1538 | if (usb_endpoint_dir_out(endpoint)) { |
1537 | dev_err(&intf->dev, "%s: interface %d. has ISO OUT endpoint!\n", | 1539 | dev_err(&intf->dev, "%s: interface %d. has ISO OUT endpoint!\n", |
1538 | __func__, ifnum); | 1540 | __func__, ifnum); |
1539 | return -ENODEV; | 1541 | ret = -ENODEV; |
1542 | goto err_usb; | ||
1540 | } | 1543 | } |
1541 | 1544 | ||
1542 | usbvision = usbvision_alloc(dev, intf); | 1545 | usbvision = usbvision_alloc(dev, intf); |
1543 | if (usbvision == NULL) { | 1546 | if (usbvision == NULL) { |
1544 | dev_err(&intf->dev, "%s: couldn't allocate USBVision struct\n", __func__); | 1547 | dev_err(&intf->dev, "%s: couldn't allocate USBVision struct\n", __func__); |
1545 | return -ENOMEM; | 1548 | ret = -ENOMEM; |
1549 | goto err_usb; | ||
1546 | } | 1550 | } |
1547 | 1551 | ||
1548 | if (dev->descriptor.bNumConfigurations > 1) | 1552 | if (dev->descriptor.bNumConfigurations > 1) |
@@ -1561,8 +1565,8 @@ static int usbvision_probe(struct usb_interface *intf, | |||
1561 | usbvision->alt_max_pkt_size = kmalloc(32 * usbvision->num_alt, GFP_KERNEL); | 1565 | usbvision->alt_max_pkt_size = kmalloc(32 * usbvision->num_alt, GFP_KERNEL); |
1562 | if (usbvision->alt_max_pkt_size == NULL) { | 1566 | if (usbvision->alt_max_pkt_size == NULL) { |
1563 | dev_err(&intf->dev, "usbvision: out of memory!\n"); | 1567 | dev_err(&intf->dev, "usbvision: out of memory!\n"); |
1564 | usbvision_release(usbvision); | 1568 | ret = -ENOMEM; |
1565 | return -ENOMEM; | 1569 | goto err_pkt; |
1566 | } | 1570 | } |
1567 | 1571 | ||
1568 | for (i = 0; i < usbvision->num_alt; i++) { | 1572 | for (i = 0; i < usbvision->num_alt; i++) { |
@@ -1597,6 +1601,12 @@ static int usbvision_probe(struct usb_interface *intf, | |||
1597 | 1601 | ||
1598 | PDEBUG(DBG_PROBE, "success"); | 1602 | PDEBUG(DBG_PROBE, "success"); |
1599 | return 0; | 1603 | return 0; |
1604 | |||
1605 | err_pkt: | ||
1606 | usbvision_release(usbvision); | ||
1607 | err_usb: | ||
1608 | usb_put_dev(dev); | ||
1609 | return ret; | ||
1600 | } | 1610 | } |
1601 | 1611 | ||
1602 | 1612 | ||