diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2021-04-22 12:02:29 +0300 |
---|---|---|
committer | Sudeep Holla <sudeep.holla@arm.com> | 2021-04-27 13:55:57 +0300 |
commit | d9cd78edb2e6b7e26747c0ec312be31e7ef196fe (patch) | |
tree | 6d9e447831f1d4fc2a1cfa68be50c7094517dd18 /drivers/firmware/arm_scmi/notify.h | |
parent | d4f9dddd21f39395c62ea12d3d91239637d4805f (diff) | |
download | linux-d9cd78edb2e6b7e26747c0ec312be31e7ef196fe.tar.xz |
firmware: arm_scpi: Prevent the ternary sign expansion bug
How the type promotion works in ternary expressions is a bit tricky.
The problem is that scpi_clk_get_val() returns longs, "ret" is a int
which holds a negative error code, and le32_to_cpu() is an unsigned int.
We want the negative error code to be cast to a negative long. But
because le32_to_cpu() is an u32 then "ret" is type promoted to u32 and
becomes a high positive and then it is promoted to long and it is still
a high positive value.
Fix this by getting rid of the ternary.
Link: https://lore.kernel.org/r/YIE7pdqV/h10tEAK@mwanda
Fixes: 8cb7cf56c9fe ("firmware: add support for ARM System Control and Power Interface(SCPI) protocol")
Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
[sudeep.holla: changed to return 0 as clock rate on error]
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Diffstat (limited to 'drivers/firmware/arm_scmi/notify.h')
0 files changed, 0 insertions, 0 deletions