Skip to content
Snippets Groups Projects
Commit b0795bbf authored by Julia Lawall's avatar Julia Lawall Committed by Greg Kroah-Hartman
Browse files

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: default avatarJulia Lawall <julia@diku.dk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 2328ceae
No related branches found
No related tags found
No related merge requests found
...@@ -289,8 +289,11 @@ static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port, ...@@ -289,8 +289,11 @@ static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port,
/* The conncected devices do not have a bulk write endpoint, /* The conncected devices do not have a bulk write endpoint,
* to transmit data to de barcode device the control endpoint is used */ * to transmit data to de barcode device the control endpoint is used */
dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_NOIO); dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_NOIO);
if (!dr) if (!dr) {
return -ENOMEM; dev_err(&port->dev, "out of memory\n");
count = -ENOMEM;
goto error;
}
dr->bRequestType = USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT; dr->bRequestType = USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT;
dr->bRequest = 0x01; dr->bRequest = 0x01;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment