Skip to contentSkip to conversation

drivers: soc: xilinx: check return status of get_api_version()

PATCH Applied Jay Buddhabhatti 2 participants 2 messages May 15, 2024 – Jun 3, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 drivers: soc: xilinx: check return status of get_api_version()

Currently 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.o
drivers/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.c
drivers/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.

Fixes b9b3a8be28b3 ("firmware: xilinx: Remove eemi ops for get_api_version")

---
V1: https://lore.kernel.org/lkml/[email protected]/
V2: https://lore.kernel.org/lkml/[email protected]/
V2->V3: Added stable tree email in cc
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
index 965b1143936a..b82c01373f53 100644
@@ -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
maintainer Applied
#1 lore raw
Quoted 33 lines · Jay Buddhabhatti

Currently 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.o
drivers/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.c
drivers/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.

Fixes b9b3a8be28b3 ("firmware: xilinx: Remove eemi ops for get_api_version")

---
V1: https://lore.kernel.org/lkml/[email protected]/
V2: https://lore.kernel.org/lkml/[email protected]/
V2->V3: Added stable tree email in cc
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 +0 -0
index 965b1143936a..b82c01373f53 100644

drivers/soc/xilinx/zynqmp_power.c static int zynqmp_pm_probe(struct platform_device *pdev) · line 198

Quoted 10 lines
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)

Applied.
M