Make sure to drop the reference taken to the DMA master OF node also on late route allocation failures.
Fixes: 134d9c52fca2 ("dmaengine: dw: dmamux: Introduce RZN1 DMA router support") Cc: stable@vger.kernel.org # 5.19 Cc: Miquel Raynal miquel.raynal@bootlin.com Signed-off-by: Johan Hovold johan@kernel.org --- drivers/dma/dw/rzn1-dmamux.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/dma/dw/rzn1-dmamux.c b/drivers/dma/dw/rzn1-dmamux.c index deadf135681b..cbec277af4dd 100644 --- a/drivers/dma/dw/rzn1-dmamux.c +++ b/drivers/dma/dw/rzn1-dmamux.c @@ -90,7 +90,7 @@ static void *rzn1_dmamux_route_allocate(struct of_phandle_args *dma_spec,
if (test_and_set_bit(map->req_idx, dmamux->used_chans)) { ret = -EBUSY; - goto free_map; + goto put_dma_spec_np; }
mask = BIT(map->req_idx); @@ -103,6 +103,8 @@ static void *rzn1_dmamux_route_allocate(struct of_phandle_args *dma_spec,
clear_bitmap: clear_bit(map->req_idx, dmamux->used_chans); +put_dma_spec_np: + of_node_put(dma_spec->np); free_map: kfree(map); put_device:
On Mon, Nov 17, 2025 at 05:12:47PM +0100, Johan Hovold wrote:
Make sure to drop the reference taken to the DMA master OF node also on late route allocation failures.
...
+put_dma_spec_np:
- of_node_put(dma_spec->np);
Can we use __free() instead?
(Just in case you are going to question the appearance of cleanup.h and the respective class in of.h, it's available in the closest stable, i.e. v6.1.108 onwards).
Hi Andy,
On 17/11/2025 at 18:05:47 +01, Andy Shevchenko andriy.shevchenko@linux.intel.com wrote:
On Mon, Nov 17, 2025 at 05:12:47PM +0100, Johan Hovold wrote:
Make sure to drop the reference taken to the DMA master OF node also on late route allocation failures.
...
+put_dma_spec_np:
- of_node_put(dma_spec->np);
Can we use __free() instead?
I probably haven't followed closely enough, but I don't understand how __free() is best than of_node_put() in front of of_parse_phandle()? Especially since the doc clearly states
"Return: The device_node pointer with refcount incremented. Use of_node_put() on it when done."
(Just in case you are going to question the appearance of cleanup.h and the respective class in of.h, it's available in the closest stable, i.e. v6.1.108 onwards).
I don't believe including a recent header is a good practice for stable inclusion anyway. I would recommend to let the commit as it is and in a follow-up patch, maybe, we can move to a newer API if we want. This way history between stable and mailine versions is easier to compare.
Reviewed-by: Miquel Raynal miquel.raynal@bootlin.com
Thanks, Miquèl
On Mon, Nov 17, 2025 at 06:05:47PM +0100, Andy Shevchenko wrote:
On Mon, Nov 17, 2025 at 05:12:47PM +0100, Johan Hovold wrote:
Make sure to drop the reference taken to the DMA master OF node also on late route allocation failures.
...
+put_dma_spec_np:
- of_node_put(dma_spec->np);
Can we use __free() instead?
I'm no fan of __free() but here it's a particularly bad fit, so no.
Johan
linux-stable-mirror@lists.linaro.org