]> git.baikalelectronics.ru Git - kernel.git/commit
media: am437x-vpfe: exclude illegal values for enum when validing params from user...
authorChangming Liu <charley.ashbringer@gmail.com>
Tue, 10 Mar 2020 21:13:20 +0000 (22:13 +0100)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 12 Mar 2020 15:26:15 +0000 (16:26 +0100)
commit0f433ce6bd482d23c88e7350db79f16b7f0f46c5
tree7af3965b1af3964fb283986d0aac1c4f87a6d4a5
parentde680fcafe2f1bcd1f76ab5ffaec14c068b9e484
media: am437x-vpfe: exclude illegal values for enum when validing params from user space

When calling ccdc_data_size_max_bit() to validate data_sz in
vpfe_ccdc_validate_param(), it's treated as an enumeration ranging from
0 to 7 while essentially it's an 32 bit unsigned integer directly from
user space. This can make the return value of ccdc_data_size_max_bit()
underflow and bypass the following check.

To fix this, an additional check is added to the following if clause to
keep this enumaration variable in range. And if its value is not legal,
return -EINVAL properly.

Signed-off-by: Changming Liu <charley.ashbringer@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/platform/am437x/am437x-vpfe.c