Commit fbfb3a75 authored by Jia-Ju Bai's avatar Jia-Ju Bai Committed by Mauro Carvalho Chehab

media: dvb-usb: Replace GFP_ATOMIC with GFP_KERNEL

Despite never getting called from atomic context,
usb URB memory allocations use GFP_ATOMIC, which does not sleep
for allocation.

GFP_ATOMIC is not necessary and can be replaced with GFP_KERNEL,
which can sleep and improve the possibility of sucessful allocation.

This is found by a static analysis tool named DCNS written by myself.
And I also manually check it.

[mchehab+samsung@kernel.org: merged 3 similar patches into one]
Signed-off-by: default avatarJia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 5ebaf328
...@@ -118,7 +118,7 @@ static int usb_allocate_stream_buffers(struct usb_data_stream *stream, int num, ...@@ -118,7 +118,7 @@ static int usb_allocate_stream_buffers(struct usb_data_stream *stream, int num,
for (stream->buf_num = 0; stream->buf_num < num; stream->buf_num++) { for (stream->buf_num = 0; stream->buf_num < num; stream->buf_num++) {
deb_mem("allocating buffer %d\n",stream->buf_num); deb_mem("allocating buffer %d\n",stream->buf_num);
if (( stream->buf_list[stream->buf_num] = if (( stream->buf_list[stream->buf_num] =
usb_alloc_coherent(stream->udev, size, GFP_ATOMIC, usb_alloc_coherent(stream->udev, size, GFP_KERNEL,
&stream->dma_addr[stream->buf_num]) ) == NULL) { &stream->dma_addr[stream->buf_num]) ) == NULL) {
deb_mem("not enough memory for urb-buffer allocation.\n"); deb_mem("not enough memory for urb-buffer allocation.\n");
usb_free_stream_buffers(stream); usb_free_stream_buffers(stream);
...@@ -145,7 +145,7 @@ static int usb_bulk_urb_init(struct usb_data_stream *stream) ...@@ -145,7 +145,7 @@ static int usb_bulk_urb_init(struct usb_data_stream *stream)
/* allocate the URBs */ /* allocate the URBs */
for (i = 0; i < stream->props.count; i++) { for (i = 0; i < stream->props.count; i++) {
stream->urb_list[i] = usb_alloc_urb(0, GFP_ATOMIC); stream->urb_list[i] = usb_alloc_urb(0, GFP_KERNEL);
if (!stream->urb_list[i]) { if (!stream->urb_list[i]) {
deb_mem("not enough memory for urb_alloc_urb!.\n"); deb_mem("not enough memory for urb_alloc_urb!.\n");
for (j = 0; j < i; j++) for (j = 0; j < i; j++)
...@@ -178,7 +178,7 @@ static int usb_isoc_urb_init(struct usb_data_stream *stream) ...@@ -178,7 +178,7 @@ static int usb_isoc_urb_init(struct usb_data_stream *stream)
struct urb *urb; struct urb *urb;
int frame_offset = 0; int frame_offset = 0;
stream->urb_list[i] = usb_alloc_urb(stream->props.u.isoc.framesperurb, GFP_ATOMIC); stream->urb_list[i] = usb_alloc_urb(stream->props.u.isoc.framesperurb, GFP_KERNEL);
if (!stream->urb_list[i]) { if (!stream->urb_list[i]) {
deb_mem("not enough memory for urb_alloc_urb!\n"); deb_mem("not enough memory for urb_alloc_urb!\n");
for (j = 0; j < i; j++) for (j = 0; j < i; j++)
......
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