Skip to content

Commit

Permalink
can: ems_usb: Improved memory handling on ems_usb_start
Browse files Browse the repository at this point in the history
Do not return from ems_usb_start if allocation fails. If not all URBs
could be allocated use the one already submitted.

Signed-off-by: Sebastian Haas <dev@sebastianhaas.info>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
  • Loading branch information
Sebastian Haas authored and Marc Kleine-Budde committed Feb 3, 2012
1 parent 9a12349 commit 2ee6850
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/net/can/usb/ems_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,8 @@ static int ems_usb_start(struct ems_usb *dev)
if (!urb) {
dev_err(netdev->dev.parent,
"No memory left for URBs\n");
return -ENOMEM;
err = -ENOMEM;
break;
}

buf = usb_alloc_coherent(dev->udev, RX_BUFFER_SIZE, GFP_KERNEL,
Expand All @@ -616,7 +617,8 @@ static int ems_usb_start(struct ems_usb *dev)
dev_err(netdev->dev.parent,
"No memory left for USB buffer\n");
usb_free_urb(urb);
return -ENOMEM;
err = -ENOMEM;
break;
}

usb_fill_bulk_urb(urb, dev->udev, usb_rcvbulkpipe(dev->udev, 2),
Expand Down

0 comments on commit 2ee6850

Please sign in to comment.