linux-stable/drivers/firmware
Dan Carpenter 4dcb3aa4a5 firmware: arm_scpi: Prevent the ternary sign expansion bug
[ Upstream commit d9cd78edb2 ]

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: 8cb7cf56c9 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-05-26 12:06:47 +02:00
..
arm_scmi firmware: arm_scmi: Fix call site of scmi_notification_exit 2021-03-04 11:37:23 +01:00
broadcom firmware: bcm47xx_sprom: Fix -Wmissing-prototypes warnings 2020-08-17 13:47:28 +02:00
efi efi/libstub: Add $(CLANG_FLAGS) to x86 flags 2021-05-11 14:47:18 +02:00
google efi: gsmi: fix false dependency on CONFIG_EFI_VARS 2020-09-29 19:40:57 +02:00
imx firmware: imx: select SOC_BUS to fix firmware build 2021-02-03 23:28:46 +01:00
meson
psci firmware: psci: Extend psci_set_osi_mode() to allow reset to PC mode 2020-09-22 17:50:32 +02:00
smccc firmware: smccc: Export both smccc functions 2020-09-14 07:30:36 +01:00
tegra firmware: tegra: fix strncpy()/strncat() confusion 2020-12-30 11:53:07 +01:00
xilinx firmware: xilinx: Fix dereferencing freed memory 2021-05-14 09:50:05 +02:00
arm_scpi.c firmware: arm_scpi: Prevent the ternary sign expansion bug 2021-05-26 12:06:47 +02:00
arm_sdei.c firmware: arm_sdei: Remove _sdei_event_unregister() 2020-09-28 21:52:23 +01:00
dmi-id.c
dmi-sysfs.c firmware: dmi-sysfs: Replace zero-length array with flexible-array member 2020-06-15 23:08:04 -05:00
dmi_scan.c Replace HTTP links with HTTPS ones: DMI/SMBIOS SUPPORT 2020-07-16 11:46:24 +02:00
edd.c
iscsi_ibft.c ibft: Replace zero-length array with flexible-array 2020-06-15 23:08:31 -05:00
iscsi_ibft_find.c
Kconfig firmware: qcom-scm: Fix QCOM_SCM configuration 2021-05-14 09:50:19 +02:00
Makefile firmware: arm_scmi: Enable building as a single module 2020-09-14 07:31:03 +01:00
memmap.c
pcdp.c
pcdp.h firmware: pcdp: Replace zero-length array with flexible-array 2020-06-15 23:08:32 -05:00
qcom_scm-legacy.c
qcom_scm-smc.c firmware: qcom_scm: Reduce locking section for __get_convention() 2021-05-14 09:50:14 +02:00
qcom_scm.c firmware: qcom_scm: Workaround lack of "is available" call on SC7180 2021-05-14 09:50:14 +02:00
qcom_scm.h firmware: qcom_scm: Reduce locking section for __get_convention() 2021-05-14 09:50:14 +02:00
qemu_fw_cfg.c fw_cfg: Add support for parisc architecture 2020-10-15 08:10:37 +02:00
raspberrypi.c Revert "firmware: raspberrypi: Introduce vl805 init routine" 2020-08-18 13:01:11 +02:00
scpi_pm_domain.c
stratix10-rsu.c firmware: stratix10-rsu: fix warnings 2020-07-02 14:48:48 +02:00
stratix10-svc.c firmware: stratix10-svc: extend svc to support new RSU features 2020-07-02 14:48:48 +02:00
ti_sci.c ARM: SoC-related driver updates 2020-10-24 10:39:22 -07:00
ti_sci.h firmware: ti_sci: Replace HTTP links with HTTPS ones 2020-07-24 14:44:52 -07:00
trusted_foundations.c
turris-mox-rwtm.c firmware: turris-mox-rwtm: support ECDSA signatures via debugfs 2020-07-18 22:35:01 +02:00