]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
media: v4l2-tpg: fix kernel oops when enabling HFLIP and OSD
authorHans Verkuil <hverkuil@xs4all.nl>
Mon, 8 Oct 2018 19:08:27 +0000 (15:08 -0400)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Tue, 9 Oct 2018 12:10:38 +0000 (08:10 -0400)
When the OSD is on (i.e. vivid displays text on top of the test pattern), and
you enable hflip, then the driver crashes.

The cause turned out to be a division of a negative number by an unsigned value.
You expect that -8 / 2U would be -4, but in reality it is 2147483644 :-(

Fixes: 3e14e7a82c1ef ("vivid-tpg: add hor/vert downsampling support to tpg_gen_text")
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reported-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Cc: <stable@vger.kernel.org> # for v4.1 and up
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/common/v4l2-tpg/v4l2-tpg-core.c

index 76b125ebee6dea5aa6285a7c9f1b74f7cfaed2de..fa483b95bc5a996a4a8bb3fe737a32c791cab5bd 100644 (file)
@@ -1801,7 +1801,7 @@ typedef struct { u16 __; u8 _; } __packed x24;
                                pos[7] = (chr & (0x01 << 0) ? fg : bg); \
                        } \
        \
-                       pos += (tpg->hflip ? -8 : 8) / hdiv;    \
+                       pos += (tpg->hflip ? -8 : 8) / (int)hdiv;       \
                }       \
        }       \
 } while (0)