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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 13 Nov 2018 19:17:02 +0000 (11:17 -0800)
commitc40015f3f3389232b22cbb98ea679d42a5604188
treed082cc908c0e4dd79b87f166585c498a98d71b21
parent5378c0eac0b76747d64bd0ab4a31229798dcf0cf
media: v4l2-tpg: fix kernel oops when enabling HFLIP and OSD

commit 250854eed5d45a73d81e4137dfd85180af6f2ec3 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/media/common/v4l2-tpg/v4l2-tpg-core.c