media: hdpvr: Add device num check and handling
authorLuke Nowakowski-Krijger <lnowakow@eng.ucsd.edu>
Wed, 17 Jul 2019 14:19:46 +0000 (10:19 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 5 Oct 2019 11:09:35 +0000 (13:09 +0200)
commit6cc816dd644e2cd6931eb89b3e1ad99f43444e41
tree392f651d7d2ae12240ba6a9a574d88fdd6d4ff84
parent8bc254d3e6b8cbe97086208782a68f881756bd63
media: hdpvr: Add device num check and handling

[ Upstream commit d4a6a9537bc32811486282206ecfb7c53754b74d ]

Add hdpvr device num check and error handling

We need to increment the device count atomically before we checkout a
device to make sure that we do not reach the max count, otherwise we get
out-of-bounds errors as reported by syzbot.

Reported-and-tested-by: syzbot+aac8d0d7205f112045d2@syzkaller.appspotmail.com
Signed-off-by: Luke Nowakowski-Krijger <lnowakow@eng.ucsd.edu>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/usb/hdpvr/hdpvr-core.c