]> git.baikalelectronics.ru Git - kernel.git/commit
firmware: arm_scmi: Fix possible scmi_linux_errmap buffer overflow
authorSudeep Holla <sudeep.holla@arm.com>
Wed, 7 Jul 2021 13:50:28 +0000 (14:50 +0100)
committerSudeep Holla <sudeep.holla@arm.com>
Mon, 12 Jul 2021 13:16:19 +0000 (14:16 +0100)
commitfdfdf3a3dc254e26c9b43a52cc6ce73d48ee2107
treec78e182c3ceb78e6b9f0df0eeeb9226399debb51
parent4bd9830d48a41575e290bf4dbdfc59c31fa4ce01
firmware: arm_scmi: Fix possible scmi_linux_errmap buffer overflow

The scmi_linux_errmap buffer access index is supposed to depend on the
array size to prevent element out of bounds access. It uses SCMI_ERR_MAX
to check bounds but that can mismatch with the array size. It also
changes the success into -EIO though scmi_linux_errmap is never used in
case of success, it is expected to work for success case too.

It is slightly confusing code as the negative of the error code
is used as index to the buffer. Fix it by negating it at the start and
make it more readable.

Link: https://lore.kernel.org/r/20210707135028.1869642-1-sudeep.holla@arm.com
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
drivers/firmware/arm_scmi/driver.c