@@ -912,7 +912,7 @@ static int redrat3_dev_probe(struct usb_interface *intf,
struct usb_endpoint_descriptor *ep_out = NULL;
u8 addr, attrs;
int pipe, i;
- int retval = -ENOMEM;
+ int retval;
uhi = intf->cur_altsetting;
@@ -951,21 +951,27 @@ static int redrat3_dev_probe(struct usb_interface *intf,
/* allocate memory for our device state and initialize it */
rr3 = kzalloc(sizeof(*rr3), GFP_KERNEL);
- if (!rr3)
+ if (!rr3) {
+ retval = -ENOMEM;
goto no_endpoints;
+ }
rr3->dev = &intf->dev;
/* set up bulk-in endpoint */
rr3->read_urb = usb_alloc_urb(0, GFP_KERNEL);
- if (!rr3->read_urb)
- goto error;
+ if (!rr3->read_urb) {
+ retval = -ENOMEM;
+ goto delete_rr;
+ }
rr3->ep_in = ep_in;
rr3->bulk_in_buf = usb_alloc_coherent(udev,
le16_to_cpu(ep_in->wMaxPacketSize), GFP_KERNEL, &rr3->dma_in);
- if (!rr3->bulk_in_buf)
- goto error;
+ if (!rr3->bulk_in_buf) {
+ retval = -ENOMEM;
+ goto delete_rr;
+ }
pipe = usb_rcvbulkpipe(udev, ep_in->bEndpointAddress);
usb_fill_bulk_urb(rr3->read_urb, udev, pipe, rr3->bulk_in_buf,
@@ -982,7 +988,7 @@ static int redrat3_dev_probe(struct usb_interface *intf,
/* might be all we need to do? */
retval = redrat3_enable_detector(rr3);
if (retval < 0)
- goto error;
+ goto delete_rr;
/* store current hardware timeout, in µs */
rr3->hw_timeout = redrat3_get_timeout(rr3);
@@ -996,7 +1002,7 @@ static int redrat3_dev_probe(struct usb_interface *intf,
rr3->led.brightness_set = redrat3_brightness_set;
retval = led_classdev_register(&intf->dev, &rr3->led);
if (retval)
- goto error;
+ goto delete_rr;
atomic_set(&rr3->flash, 0);
rr3->flash_urb = usb_alloc_urb(0, GFP_KERNEL);
@@ -1028,7 +1034,7 @@ static int redrat3_dev_probe(struct usb_interface *intf,
led_free_error:
led_classdev_unregister(&rr3->led);
-error:
+delete_rr:
redrat3_delete(rr3, rr3->udev);
no_endpoints: