]> git.hungrycats.org Git - linux/commit
media: v4l2-tpg: prevent the risk of a division by zero
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Wed, 16 Oct 2024 09:53:15 +0000 (11:53 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 17 Nov 2024 13:59:36 +0000 (14:59 +0100)
commit054931ca3cfcb8e8fa036e887d6f379942b02565
treef1cfa92e3b88ce6e4766120c6d8ad824b2cbf66e
parent5a9bd375bf884d928d6f954d3ab328d2f84024a9
media: v4l2-tpg: prevent the risk of a division by zero

commit e6a3ea83fbe15d4818d01804e904cbb0e64e543b upstream.

As reported by Coverity, the logic at tpg_precalculate_line()
blindly rescales the buffer even when scaled_witdh is equal to
zero. If this ever happens, this will cause a division by zero.

Instead, add a WARN_ON_ONCE() to trigger such cases and return
without doing any precalculation.

Fixes: 63881df94d3e ("[media] vivid: add the Test Pattern Generator")
Cc: stable@vger.kernel.org
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/media/common/v4l2-tpg/v4l2-tpg-core.c