* [PATCH] drivers: soc: xilinx: check return status of get_api_version()
@ 2024-04-24 6:31 Jay Buddhabhatti
2024-04-24 21:34 ` Greg KH
2024-04-25 10:01 ` [PATCH v2] " Jay Buddhabhatti
0 siblings, 2 replies; 3+ messages in thread
From: Jay Buddhabhatti @ 2024-04-24 6:31 UTC (permalink / raw)
To: michal.simek, gregkh; +Cc: linux-arm-kernel, linux-kernel, Jay Buddhabhatti
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".
Fixes: b9b3a8be28b3 ("firmware: xilinx: Remove eemi ops for get_api_version")
Signed-off-by: Jay Buddhabhatti <jay.buddhabhatti@amd.com>
---
drivers/soc/xilinx/zynqmp_power.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/soc/xilinx/zynqmp_power.c b/drivers/soc/xilinx/zynqmp_power.c
index 965b1143936a..8570ab1a6857 100644
--- a/drivers/soc/xilinx/zynqmp_power.c
+++ b/drivers/soc/xilinx/zynqmp_power.c
@@ -3,6 +3,7 @@
* Xilinx Zynq MPSoC Power Management
*
* Copyright (C) 2014-2019 Xilinx, Inc.
+ * Copyright (C) 2024, Advanced Micro Devices, Inc.
*
* Davorin Mista <davorin.mista@aggios.com>
* Jolly Shah <jollys@xilinx.com>
@@ -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)
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drivers: soc: xilinx: check return status of get_api_version()
2024-04-24 6:31 [PATCH] drivers: soc: xilinx: check return status of get_api_version() Jay Buddhabhatti
@ 2024-04-24 21:34 ` Greg KH
2024-04-25 10:01 ` [PATCH v2] " Jay Buddhabhatti
1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2024-04-24 21:34 UTC (permalink / raw)
To: Jay Buddhabhatti; +Cc: michal.simek, linux-arm-kernel, linux-kernel
On Tue, Apr 23, 2024 at 11:31:18PM -0700, Jay Buddhabhatti wrote:
> 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".
>
> Fixes: b9b3a8be28b3 ("firmware: xilinx: Remove eemi ops for get_api_version")
> Signed-off-by: Jay Buddhabhatti <jay.buddhabhatti@amd.com>
> ---
> drivers/soc/xilinx/zynqmp_power.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/soc/xilinx/zynqmp_power.c b/drivers/soc/xilinx/zynqmp_power.c
> index 965b1143936a..8570ab1a6857 100644
> --- a/drivers/soc/xilinx/zynqmp_power.c
> +++ b/drivers/soc/xilinx/zynqmp_power.c
> @@ -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
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] drivers: soc: xilinx: check return status of get_api_version()
2024-04-24 6:31 [PATCH] drivers: soc: xilinx: check return status of get_api_version() Jay Buddhabhatti
2024-04-24 21:34 ` Greg KH
@ 2024-04-25 10:01 ` Jay Buddhabhatti
1 sibling, 0 replies; 3+ messages in thread
From: Jay Buddhabhatti @ 2024-04-25 10:01 UTC (permalink / raw)
To: michal.simek, gregkh; +Cc: linux-arm-kernel, linux-kernel, 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")
Signed-off-by: Jay Buddhabhatti <jay.buddhabhatti@amd.com>
---
V1: https://lore.kernel.org/lkml/20240424063118.23200-1-jay.buddhabhatti@amd.com/
V1->V2: Removed AMD copyright
---
drivers/soc/xilinx/zynqmp_power.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/soc/xilinx/zynqmp_power.c b/drivers/soc/xilinx/zynqmp_power.c
index 965b1143936a..b82c01373f53 100644
--- a/drivers/soc/xilinx/zynqmp_power.c
+++ b/drivers/soc/xilinx/zynqmp_power.c
@@ -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)
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-04-25 10:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-24 6:31 [PATCH] drivers: soc: xilinx: check return status of get_api_version() Jay Buddhabhatti
2024-04-24 21:34 ` Greg KH
2024-04-25 10:01 ` [PATCH v2] " Jay Buddhabhatti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox