media: af9035: prevent buffer overflow on write
authorJozef Balga <jozef.balga@gmail.com>
Tue, 21 Aug 2018 09:01:04 +0000 (05:01 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 20 Oct 2018 07:48:47 +0000 (09:48 +0200)
commit88be243901ff08770981d497b188a8a323cd7f56
treeba098c038430f24fdc2ab569c2cc6f572330e80a
parent8263087bf62739362d50ec965c8c34fe3ee7a7cd
media: af9035: prevent buffer overflow on write

[ Upstream commit 312f73b648626a0526a3aceebb0a3192aaba05ce ]

When less than 3 bytes are written to the device, memcpy is called with
negative array size which leads to buffer overflow and kernel panic. This
patch adds a condition and returns -EOPNOTSUPP instead.
Fixes bugzilla issue 64871

[mchehab+samsung@kernel.org: fix a merge conflict and changed the
 condition to match the patch's comment, e. g. len == 3 could
 also be valid]
Signed-off-by: Jozef Balga <jozef.balga@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/media/usb/dvb-usb-v2/af9035.c