* [PATCH v2] arm: fix uninitialized pointers with free attr
@ 2025-12-03 15:22 Ally Heev
2025-12-03 15:51 ` Sudeep Holla
0 siblings, 1 reply; 2+ messages in thread
From: Ally Heev @ 2025-12-03 15:22 UTC (permalink / raw)
To: Sudeep Holla, Cristian Marussi
Cc: arm-scmi, linux-arm-kernel, linux-kernel, Dan Carpenter,
Ally Heev
Uninitialized pointers with `__free` attribute can cause undefined
behaviour as the memory assigned(randomly) to the pointer is freed
automatically when the pointer goes out of scope
arm doesn't have any bugs related to this as of now, but
it is better to initialize and assign pointers with `__free` attr
in one statement to ensure proper scope-based cleanup
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/all/aPiG_F5EBQUjZqsl@stanley.mountain/
Signed-off-by: Ally Heev <allyheev@gmail.com>
Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
---
Changes in v2:
- added Reviewed-by trailer
- Link to v1: https://lore.kernel.org/r/20251105-aheev-uninitialized-free-attr-arm-v1-1-f7b6cb5d3361@gmail.com
---
drivers/firmware/arm_scmi/shmem.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/firmware/arm_scmi/shmem.c b/drivers/firmware/arm_scmi/shmem.c
index 11c347bff766763c61100f884432c2e4669e5918..dadb37557f8aee25465e1a423dfcb4a889852434 100644
--- a/drivers/firmware/arm_scmi/shmem.c
+++ b/drivers/firmware/arm_scmi/shmem.c
@@ -196,7 +196,6 @@ static void __iomem *shmem_setup_iomap(struct scmi_chan_info *cinfo,
struct resource *res,
struct scmi_shmem_io_ops **ops)
{
- struct device_node *shmem __free(device_node);
const char *desc = tx ? "Tx" : "Rx";
int ret, idx = tx ? 0 : 1;
struct device *cdev = cinfo->dev;
@@ -205,7 +204,9 @@ static void __iomem *shmem_setup_iomap(struct scmi_chan_info *cinfo,
void __iomem *addr;
u32 reg_io_width;
- shmem = of_parse_phandle(cdev->of_node, "shmem", idx);
+ struct device_node *shmem __free(device_node) = of_parse_phandle(cdev->of_node,
+ "shmem", idx);
+
if (!shmem)
return IOMEM_ERR_PTR(-ENODEV);
---
base-commit: c9cfc122f03711a5124b4aafab3211cf4d35a2ac
change-id: 20251105-aheev-uninitialized-free-attr-arm-cf3516ba1a18
Best regards,
--
Ally Heev <allyheev@gmail.com>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] arm: fix uninitialized pointers with free attr
2025-12-03 15:22 [PATCH v2] arm: fix uninitialized pointers with free attr Ally Heev
@ 2025-12-03 15:51 ` Sudeep Holla
0 siblings, 0 replies; 2+ messages in thread
From: Sudeep Holla @ 2025-12-03 15:51 UTC (permalink / raw)
To: Ally Heev
Cc: Cristian Marussi, arm-scmi, Sudeep Holla, linux-arm-kernel,
linux-kernel, Dan Carpenter
On Wed, Dec 03, 2025 at 08:52:34PM +0530, Ally Heev wrote:
> Uninitialized pointers with `__free` attribute can cause undefined
> behaviour as the memory assigned(randomly) to the pointer is freed
> automatically when the pointer goes out of scope
>
> arm doesn't have any bugs related to this as of now, but
> it is better to initialize and assign pointers with `__free` attr
> in one statement to ensure proper scope-based cleanup
>
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://lore.kernel.org/all/aPiG_F5EBQUjZqsl@stanley.mountain/
> Signed-off-by: Ally Heev <allyheev@gmail.com>
> Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
> ---
> Changes in v2:
> - added Reviewed-by trailer
Ideally, there is no need to repost the same patch with just trailers added.
Sorry for no response, I plan to queue this at -rc1 as fix, so please give
me some time to officially apply at -rc1. I have put this a branch, so I won't
miss this but may need to rebase and hence silence.
--
Regards,
Sudeep
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-12-03 15:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-03 15:22 [PATCH v2] arm: fix uninitialized pointers with free attr Ally Heev
2025-12-03 15:51 ` Sudeep Holla
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox