diff options
author | Julia Lawall <julia@diku.dk> | 2011-05-13 11:30:46 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-05-13 18:51:08 -0400 |
commit | b0795bbf6dc6bd0a7a37d9d1ef4558e9e2b0acd6 (patch) | |
tree | 92e6f17971bf9c4ec0042c654f6a386b0286e051 | |
parent | 2328ceaea4fb917f8b861b18151b2245233b083f (diff) |
drivers/usb/serial/opticon.c: Release resources on kmalloc failure
Several resources have been allocated before this kmalloc failure, and thus
they should be released in this error handling code, as done in nearby
error handling code.
The semantic match that finds this problem is:
(http://coccinelle.lip6.fr/)
// <smpl>
@r exists@
local idexpression urb;
statement S;
position p1,p2;
@@
urb = usb_alloc_urb@p1(...);
... when != urb
if (urb == NULL) S
... when != urb
(
return <+...urb...+>;
|
return@p2 ...;
)
@script:python@
p1 << r.p1;
p2 << r.p2;
@@
cocci.print_main("",p1)
cocci.print_secs("",p2)
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/usb/serial/opticon.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c index 1b5633f46984..96423f3c8ef3 100644 --- a/drivers/usb/serial/opticon.c +++ b/drivers/usb/serial/opticon.c | |||
@@ -289,8 +289,11 @@ static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
289 | /* The conncected devices do not have a bulk write endpoint, | 289 | /* The conncected devices do not have a bulk write endpoint, |
290 | * to transmit data to de barcode device the control endpoint is used */ | 290 | * to transmit data to de barcode device the control endpoint is used */ |
291 | dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_NOIO); | 291 | dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_NOIO); |
292 | if (!dr) | 292 | if (!dr) { |
293 | return -ENOMEM; | 293 | dev_err(&port->dev, "out of memory\n"); |
294 | count = -ENOMEM; | ||
295 | goto error; | ||
296 | } | ||
294 | 297 | ||
295 | dr->bRequestType = USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT; | 298 | dr->bRequestType = USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT; |
296 | dr->bRequest = 0x01; | 299 | dr->bRequest = 0x01; |