drivers: soc: xilinx: check return status of get_api_version()
PATCH 1/1 drivers: soc: xilinx: check return status of get_api_version()
Check return status of pm_get_api_version and return error in case of failure to avoid checking uninitialized pm_api_version variable from stack.
The issue is also reported by smatch on x86 as "warning: 'pm_api_version' is used uninitialized".
--- drivers/soc/xilinx/zynqmp_power.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/soc/xilinx/zynqmp_power.c +4 -1
@@ -3,6 +3,7 @@* Xilinx Zynq MPSoC Power Management * * Copyright (C) 2014-2019 Xilinx, Inc. +* Copyright (C) 2024, Advanced Micro Devices, Inc. * * Davorin Mista <[email protected]> * Jolly Shah <[email protected]>
@@ -190,7 +191,9 @@ static int zynqmp_pm_probe(struct platform_device *pdev)u32 pm_api_version;struct mbox_client *client; -zynqmp_pm_get_api_version (&pm_api_version); + ret =zynqmp_pm_get_api_version (&pm_api_version); +if (ret) +return ret;/* Check PM API version number */ if (pm_api_version <ZYNQMP_PM_VERSION )
Signature · 1 line
2.17.1
Quoted 17 lines · Jay Buddhabhatti
Check return status of
pm_get_api_versionand return error in case of failure to avoid checking uninitializedpm_api_versionvariable from stack.The issue is also reported by smatch on x86 as "warning: '
pm_api_version' is used uninitialized".Fixes b9b3a8be28b3 ("firmware: xilinx: Remove eemi ops for get_api_version")Signed-off-by Jay Buddhabhatti <[email protected]>--- drivers/soc/xilinx/zynqmp_power.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/soc/xilinx/zynqmp_power.c +0
-0
drivers/soc/xilinx/zynqmp_power.c line 6
Quoted 4 lines
drivers/soc/xilinx/zynqmp_power.c +1
-0@@ -3,6 +3,7 @@* Xilinx Zynq MPSoC Power Management * * Copyright (C) 2014-2019 Xilinx, Inc. +* Copyright (C) 2024, Advanced Micro Devices, Inc.
Really? Your lawyers think that your 3 line change deserves this addition as well? If so, please have them sign off on the next version of this patch submission so that we get their confirmation that this is what they want to start doing for all AMD submissions.
From my point of view, this change is not ok.
thanks,
greg "I talk to too many lawyers" k-h
PATCH v2 1/1 drivers: soc: xilinx: check return status of get_api_version()
In reply to Jay BuddhabhattiCurrently return status is not getting checked for get_api_version and because of that for x86 arch we are getting below smatch error.
CC drivers/soc/xilinx/zynqmp_power.odrivers/soc/xilinx/zynqmp_power.c: In function 'zynqmp_pm_probe':drivers/soc/xilinx/zynqmp_power.c:295:12: warning: 'pm_api_version' is used uninitialized [-Wuninitialized]
295 | if (pm_api_version < ZYNQMP_PM_VERSION)
| ^
CHECK drivers/soc/xilinx/zynqmp_power.cdrivers/soc/xilinx/zynqmp_power.c:295 zynqmp_pm_probe() error:
uninitialized symbol 'pm_api_version'.
So, check return status of pm_get_api_version and return error in case of failure to avoid checking uninitialized pm_api_version variable.
---
V1: https://lore.kernel.org/lkml/[email protected]/V1->V2: Removed AMD copyright
--- drivers/soc/xilinx/zynqmp_power.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/soc/xilinx/zynqmp_power.c +3 -1
@@ -190,7 +190,9 @@ static int zynqmp_pm_probe(struct platform_device *pdev)u32 pm_api_version;struct mbox_client *client; -zynqmp_pm_get_api_version (&pm_api_version); + ret =zynqmp_pm_get_api_version (&pm_api_version); +if (ret) +return ret;/* Check PM API version number */ if (pm_api_version <ZYNQMP_PM_VERSION )
Signature · 1 line
2.17.1