[bug report] media: nuvoton: Add driver for NPCM video capture and encoding engine

Dan Carpenter dan.carpenter at linaro.org
Wed Sep 27 00:23:35 AEST 2023


Hello Marvin Lin,

The patch 70721089985c: "media: nuvoton: Add driver for NPCM video
capture and encoding engine" from Sep 22, 2023 (linux-next), leads to
the following Smatch static checker warning:

	drivers/media/platform/nuvoton/npcm-video.c:1004 npcm_video_raw()
	warn: sleeping in atomic context

drivers/media/platform/nuvoton/npcm-video.c
    998 static unsigned int npcm_video_raw(struct npcm_video *video, int index, void *addr)
    999 {
    1000         unsigned int width = video->active_timings.width;
    1001         unsigned int height = video->active_timings.height;
    1002         unsigned int i, len, offset, bytes = 0;
    1003 
--> 1004         video->rect[index] = npcm_video_add_rect(video, index, 0, 0, width, height);
                                      ^^^^^^^^^^^^^^^^^^^
This function does a sleeping allocation (GFP_KERNEL).  However
npcm_video_irq() is holding spin_lock(&video->lock); so this is a
sleeping in atomic bug.

    1005 
    1006         for (i = 0; i < height; i++) {
    1007                 len = width * video->bytesperpixel;
    1008                 offset = i * video->bytesperline;
    1009 
    1010                 memcpy(addr + bytes, video->src.virt + offset, len);
    1011                 bytes += len;
    1012         }
    1013 
    1014         return bytes;
    1015 }

regards,
dan carpenter


More information about the openbmc mailing list