* [PATCH] media: nuvoton: npcm-video: Fix sleeping in atomic context
@ 2023-10-03 7:55 Marvin Lin
2023-10-03 13:23 ` Hans Verkuil
0 siblings, 1 reply; 3+ messages in thread
From: Marvin Lin @ 2023-10-03 7:55 UTC (permalink / raw)
To: mchehab, hverkuil-cisco
Cc: dan.carpenter, linux-media, linux-kernel, openbmc, avifishman70,
tmaimon77, kwliu, kflin, Marvin Lin
Fix sleeping in atomic context warnings reported by the Smatch static
analysis tool. Use GFP_ATOMIC instead of GFP_KERNEL in atomic context.
Fixes: 70721089985c ("media: nuvoton: Add driver for NPCM video capture and encoding engine")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Marvin Lin <milkfafa@gmail.com>
---
drivers/media/platform/nuvoton/npcm-video.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/nuvoton/npcm-video.c b/drivers/media/platform/nuvoton/npcm-video.c
index ac8d73b794d3..5d160978f7b3 100644
--- a/drivers/media/platform/nuvoton/npcm-video.c
+++ b/drivers/media/platform/nuvoton/npcm-video.c
@@ -412,7 +412,7 @@ static unsigned int npcm_video_add_rect(struct npcm_video *video,
struct rect_list *list = NULL;
struct v4l2_rect *r;
- list = kzalloc(sizeof(*list), GFP_KERNEL);
+ list = kzalloc(sizeof(*list), GFP_ATOMIC);
if (!list)
return 0;
@@ -467,7 +467,7 @@ static struct rect_list *npcm_video_new_rect(struct npcm_video *video,
struct rect_list *list = NULL;
struct v4l2_rect *r;
- list = kzalloc(sizeof(*list), GFP_KERNEL);
+ list = kzalloc(sizeof(*list), GFP_ATOMIC);
if (!list)
return NULL;
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] media: nuvoton: npcm-video: Fix sleeping in atomic context
2023-10-03 7:55 [PATCH] media: nuvoton: npcm-video: Fix sleeping in atomic context Marvin Lin
@ 2023-10-03 13:23 ` Hans Verkuil
2023-10-10 12:30 ` Kun-Fa Lin
0 siblings, 1 reply; 3+ messages in thread
From: Hans Verkuil @ 2023-10-03 13:23 UTC (permalink / raw)
To: Marvin Lin, mchehab
Cc: dan.carpenter, linux-media, linux-kernel, openbmc, avifishman70,
tmaimon77, kwliu, kflin
On 10/3/23 09:55, Marvin Lin wrote:
> Fix sleeping in atomic context warnings reported by the Smatch static
> analysis tool. Use GFP_ATOMIC instead of GFP_KERNEL in atomic context.
>
> Fixes: 70721089985c ("media: nuvoton: Add driver for NPCM video capture and encoding engine")
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Signed-off-by: Marvin Lin <milkfafa@gmail.com>
> ---
> drivers/media/platform/nuvoton/npcm-video.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/platform/nuvoton/npcm-video.c b/drivers/media/platform/nuvoton/npcm-video.c
> index ac8d73b794d3..5d160978f7b3 100644
> --- a/drivers/media/platform/nuvoton/npcm-video.c
> +++ b/drivers/media/platform/nuvoton/npcm-video.c
> @@ -412,7 +412,7 @@ static unsigned int npcm_video_add_rect(struct npcm_video *video,
> struct rect_list *list = NULL;
> struct v4l2_rect *r;
>
> - list = kzalloc(sizeof(*list), GFP_KERNEL);
> + list = kzalloc(sizeof(*list), GFP_ATOMIC);
> if (!list)
> return 0;
>
> @@ -467,7 +467,7 @@ static struct rect_list *npcm_video_new_rect(struct npcm_video *video,
> struct rect_list *list = NULL;
> struct v4l2_rect *r;
>
> - list = kzalloc(sizeof(*list), GFP_KERNEL);
> + list = kzalloc(sizeof(*list), GFP_ATOMIC);
> if (!list)
> return NULL;
>
I'm not really sure this is the right approach.
Looking closer at the code I notice that npcm_video_irq is a threaded
interrupt handler, so wouldn't it be easier to change the video->lock
spinlock to a mutex?
Regards,
Hans
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] media: nuvoton: npcm-video: Fix sleeping in atomic context
2023-10-03 13:23 ` Hans Verkuil
@ 2023-10-10 12:30 ` Kun-Fa Lin
0 siblings, 0 replies; 3+ messages in thread
From: Kun-Fa Lin @ 2023-10-10 12:30 UTC (permalink / raw)
To: Hans Verkuil
Cc: mchehab, dan.carpenter, linux-media, linux-kernel, openbmc,
avifishman70, tmaimon77, kwliu, kflin
Hi Hans,
Thanks for the review.
> > - list = kzalloc(sizeof(*list), GFP_KERNEL);
> > + list = kzalloc(sizeof(*list), GFP_ATOMIC);
> > if (!list)
> > return NULL;
> >
>
> I'm not really sure this is the right approach.
>
> Looking closer at the code I notice that npcm_video_irq is a threaded
> interrupt handler, so wouldn't it be easier to change the video->lock
> spinlock to a mutex?
>
Agree it's better to use mutex. Will send v2 for this.
Regards,
Marvin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-10 12:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-03 7:55 [PATCH] media: nuvoton: npcm-video: Fix sleeping in atomic context Marvin Lin
2023-10-03 13:23 ` Hans Verkuil
2023-10-10 12:30 ` Kun-Fa Lin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®