Re: [PATCH v2] clk: eyeq: fix memory leak in eqc_auxdev_create() error path
From: Théo Lebrun
Date: Mon Apr 13 2026 - 04:07:06 EST
Hello Guangshuo,
Subject is:
> Subject: [PATCH v2] clk: eyeq: fix memory leak in eqc_auxdev_create()
> error path
I cannot find a public V1?
https://lore.kernel.org/lkml/?q=s%3Aeyeq+f%3AGuangshuo
On Sun Apr 12, 2026 at 2:42 PM CEST, Guangshuo Li wrote:
> eqc_auxdev_create() allocates an auxiliary_device with kzalloc() before
> calling auxiliary_device_init().
>
> When auxiliary_device_init() returns an error, the function exits
> without freeing adev. Since the release callback is only expected to
> handle cleanup after successful initialization, adev should be freed
> explicitly in this path.
>
> Add the missing kfree(adev) before returning from the
> auxiliary_device_init() error path.
>
> Fixes: 25d904946a0b ("clk: eyeq: add driver")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Guangshuo Li <lgs201920130244@xxxxxxxxx>
I have a guess this is LLM generated?
Are you missing the Assisted-by trailer?
https://docs.kernel.org/process/coding-assistants.html#attribution
The patch could be in theory useful.
In practice however, it's a different story.
- Comit message says "Since the release callback is only expected to
handle cleanup after successful initialization, adev should be freed
explicitly in this path".
Two things are wrong here:
1. the driver cannot be removed so there is no "release
callback" (guessing you mean driver remove?).
2. this text seems to imply eqc_auxdev_create() makes probe fail,
which it doesn't. It only generates a warning and keeps probing.
- This driver cannot be built as module (will always be probed at boot)
and cannot be removed. So the "leak" we are talking about is
2 * sizeof(struct auxiliary_device)
But in no sensible case it can occur. The platforms that use this
driver probably cannot boot if our auxiliary drivers aren't present.
So if eqc_auxdev_create() fails then the warning is here to be nice
but you probably will fail booting afterwards.
My guess is: you might succeed booting without the reset driver but
if you fail the pinctrl one then you won't have a UART. Anyway in no
world do you have a sensible EyeQ kernel config that leads to
clk-eyeq probing but not its auxdevs.
- If you fix this then there are other resources cleanup to "fix".
- ioremap() in eqc_probe()
- kzalloc of cells in eqc_probe()
- probably others
But, same as above, "fixing" those will only be useful in kernels
that will panic in a few milliseconds.
Thanks,
--
Théo Lebrun, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com