Skip to contentSkip to conversation

media: uvcvideo: fix GFP_ flags in uvc_submit_urb()

PATCH In review Dan Carpenter 2 participants 3 messages Mar 19, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: uvcvideo: fix GFP_ flags in uvc_submit_urb()

The uvc_submit_urb() function is supposed to use the passed in GFP_ flags but this code accidentally uses GFP_KERNEL instead. Some of the callers are passing GFP_ATOMIC so presumably this can lead to sleeping in atomic context.

Fixes b20f917f84e6 ("media: uvcvideo: Use dma_alloc_noncontiguous API")
---
 drivers/media/usb/uvc/uvc_video.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/uvc/uvc_video.c +1 -1
index cdd8eb500bb7..a777b389a66e 100644
@@ -1119,7 +1119,7 @@ static int uvc_submit_urb(struct uvc_urb *uvc_urb, gfp_t mem_flags)
 	dma_sync_sgtable_for_device(uvc_stream_to_dmadev(uvc_urb->stream),
 				    uvc_urb->sgt,
 				    uvc_stream_dir(uvc_urb->stream));
-	return usb_submit_urb(uvc_urb->urb, GFP_KERNEL);
+	return usb_submit_urb(uvc_urb->urb, mem_flags);
 }
 
 /*
Signature · 1 line
2.30.2
#1 lore raw

Hi Dan

Quoted 8 lines · Dan Carpenter

The uvc_submit_urb() function is supposed to use the passed in GFP_ flags but this code accidentally uses GFP_KERNEL instead. Some of the callers are passing GFP_ATOMIC so presumably this can lead to sleeping in atomic context.

Fixes b20f917f84e6 ("media: uvcvideo: Use dma_alloc_noncontiguous API")

I reported the same issue just some minutes ago. Christoph has already fixed the patch in his tree.

Where did you get the patchset? from next? from linus? or directly from Chirstoph tree?

Thanks!

Quoted 20 lines
---
 drivers/media/usb/uvc/uvc_video.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/uvc/uvc_video.c +1 -2
index cdd8eb500bb7..a777b389a66e 100644
@@ -1119,7 +1119,7 @@ static int uvc_submit_urb(struct uvc_urb *uvc_urb, gfp_t mem_flags)
        dma_sync_sgtable_for_device(uvc_stream_to_dmadev(uvc_urb->stream),
                                    uvc_urb->sgt,
                                    uvc_stream_dir(uvc_urb->stream));
-       return usb_submit_urb(uvc_urb->urb, GFP_KERNEL);
+       return usb_submit_urb(uvc_urb->urb, mem_flags);
 }
 
 /*
--

2.30.2

Signature · 1 line
Ricardo Ribalda
#2 lore raw
Quoted 9 lines · Ricardo Ribalda Delgado

Hi Dan

Quoted 6 lines · Dan Carpenter

The uvc_submit_urb() function is supposed to use the passed in GFP_ flags but this code accidentally uses GFP_KERNEL instead. Some of the callers are passing GFP_ATOMIC so presumably this can lead to sleeping in atomic context.

Quoted 8 lines
Quoted 2 lines
Fixes b20f917f84e6 ("media: uvcvideo: Use dma_alloc_noncontiguous API")

I reported the same issue just some minutes ago. Christoph has already fixed the patch in his tree.

Where did you get the patchset? from next? from linus? or directly from Chirstoph tree?

From linux-next. I'm not sure if it was from yesterday's linux-next or from a couple days ago.

regards,
dan carpenter