Commit 22505b25 authored by Alexey Khoroshilov's avatar Alexey Khoroshilov Committed by Greg Kroah-Hartman

staging: gdm724x: fix leak at failure path in init_usb()

If an allocation in init_usb() failed, it returns without
deallocation of already allocated resources.

The patch fix it and replaces GFP_ATOMIC by GFP_KERNEL in
alloc_tx_sdu_struct() and alloc_rx_struct() as long as
they are called from probe only.

Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: default avatarAlexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4f4756fc
...@@ -125,11 +125,11 @@ static struct usb_tx_sdu *alloc_tx_sdu_struct(void) ...@@ -125,11 +125,11 @@ static struct usb_tx_sdu *alloc_tx_sdu_struct(void)
{ {
struct usb_tx_sdu *t_sdu; struct usb_tx_sdu *t_sdu;
t_sdu = kzalloc(sizeof(struct usb_tx_sdu), GFP_ATOMIC); t_sdu = kzalloc(sizeof(struct usb_tx_sdu), GFP_KERNEL);
if (!t_sdu) if (!t_sdu)
return NULL; return NULL;
t_sdu->buf = kmalloc(SDU_BUF_SIZE, GFP_ATOMIC); t_sdu->buf = kmalloc(SDU_BUF_SIZE, GFP_KERNEL);
if (!t_sdu->buf) { if (!t_sdu->buf) {
kfree(t_sdu); kfree(t_sdu);
return NULL; return NULL;
...@@ -183,14 +183,14 @@ static struct usb_rx *alloc_rx_struct(void) ...@@ -183,14 +183,14 @@ static struct usb_rx *alloc_rx_struct(void)
struct usb_rx *r = NULL; struct usb_rx *r = NULL;
int ret = 0; int ret = 0;
r = kmalloc(sizeof(struct usb_rx), GFP_ATOMIC); r = kmalloc(sizeof(struct usb_rx), GFP_KERNEL);
if (!r) { if (!r) {
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
} }
r->urb = usb_alloc_urb(0, GFP_ATOMIC); r->urb = usb_alloc_urb(0, GFP_KERNEL);
r->buf = kmalloc(RX_BUF_SIZE, GFP_ATOMIC); r->buf = kmalloc(RX_BUF_SIZE, GFP_KERNEL);
if (!r->urb || !r->buf) { if (!r->urb || !r->buf) {
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
...@@ -366,6 +366,7 @@ static int init_usb(struct lte_udev *udev) ...@@ -366,6 +366,7 @@ static int init_usb(struct lte_udev *udev)
INIT_DELAYED_WORK(&udev->work_rx, do_rx); INIT_DELAYED_WORK(&udev->work_rx, do_rx);
return 0; return 0;
fail: fail:
release_usb(udev);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment