]> git.baikalelectronics.ru Git - kernel.git/commit
media: cec: silence shift wrapping warning in __cec_s_log_addrs()
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 5 May 2020 08:25:56 +0000 (10:25 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tue, 5 May 2020 15:27:03 +0000 (17:27 +0200)
commit41a1e6e721bd39625f75602b65455a5262986c39
tree40ecc19c0e87ea2777814bea7c3aaea7ac4b1c54
parente795e5da9dd9b9121bd2a73bd77ebcc88bd75ef1
media: cec: silence shift wrapping warning in __cec_s_log_addrs()

The log_addrs->log_addr_type[i] value is a u8 which is controlled by
the user and comes from the ioctl.  If it's over 31 then that results in
undefined behavior (shift wrapping) and that leads to a Smatch static
checker warning.  We already cap the value later so we can silence the
warning just by re-ordering the existing checks.

I think the UBSan checker will also catch this bug at runtime and
generate a warning.  But otherwise the bug is harmless.

Fixes: 235327c8e7e5 ("[media] cec: add HDMI CEC framework (adapter)")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/cec/core/cec-adap.c