]> git.baikalelectronics.ru Git - kernel.git/commit
media: pvrusb2: fix array-index-out-of-bounds in pvr2_i2c_core_init
authorPavel Skripkin <paskripkin@gmail.com>
Fri, 15 Apr 2022 21:24:48 +0000 (23:24 +0200)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Fri, 13 May 2022 09:02:19 +0000 (11:02 +0200)
commite3ec1c0a4c646c4e37c4cab52dc0733d03167ae0
tree2e326bdedcabe6d571e128a6c4b516352e9c961c
parente156de28f20abdb471e8e0abae452a32d72c6cfa
media: pvrusb2: fix array-index-out-of-bounds in pvr2_i2c_core_init

Syzbot reported that -1 is used as array index. The problem was in
missing validation check.

hdw->unit_number is initialized with -1 and then if init table walk fails
this value remains unchanged. Since code blindly uses this member for
array indexing adding sanity check is the easiest fix for that.

hdw->workpoll initialization moved upper to prevent warning in
__flush_work.

Reported-and-tested-by: syzbot+1a247e36149ffd709a9b@syzkaller.appspotmail.com
Fixes: 5e59f9f44dd8 ("V4L/DVB (4228a): pvrusb2 to kernel 2.6.18")
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/usb/pvrusb2/pvrusb2-hdw.c