media: staging: media: zoran: calculate the right buffer number for zoran_reap_stat_com
authorCorentin Labbe <clabbe@baylibre.com>
Tue, 14 Dec 2021 16:16:32 +0000 (17:16 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Apr 2022 12:23:58 +0000 (14:23 +0200)
commit7e76f3ed7ab2ae026c6ef9cc23096a7554af8c52
tree21bc4d0a418d11660dc5d400916e4b0239b4bb59
parentff3357bffd9fb78f59762d8955afc7382a279079
media: staging: media: zoran: calculate the right buffer number for zoran_reap_stat_com

[ Upstream commit e3b86f4e558cea9eed71d894df2f19b10d60a207 ]

On the case tmp_dcim=1, the index of buffer is miscalculated.
This generate a NULL pointer dereference later.

So let's fix the calcul and add a check to prevent this to reappear.

Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/staging/media/zoran/zoran_device.c