Skip to content

Commit 926d166

Browse files
jhovoldgregkh
authored andcommitted
dmaengine: sh: rz-dmac: fix device leak on probe failure
commit 9fb490323997dcb6f749cd2660a17a39854600cd upstream. Make sure to drop the reference taken when looking up the ICU device during probe also on probe failures (e.g. probe deferral). Fixes: 7de8732 ("dmaengine: sh: rz-dmac: Add RZ/V2H(P) support") Cc: stable@vger.kernel.org # 6.16 Cc: Fabrizio Castro <fabrizio.castro.jz@renesas.com> Signed-off-by: Johan Hovold <johan@kernel.org> Reviewed-by: Fabrizio Castro <fabrizio.castro.jz@renesas.com> Link: https://patch.msgid.link/20251117161258.10679-10-johan@kernel.org Signed-off-by: Vinod Koul <vkoul@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 55a67ba commit 926d166

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

drivers/dma/sh/rz-dmac.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,13 @@ static int rz_dmac_chan_probe(struct rz_dmac *dmac,
854854
return 0;
855855
}
856856

857+
static void rz_dmac_put_device(void *_dev)
858+
{
859+
struct device *dev = _dev;
860+
861+
put_device(dev);
862+
}
863+
857864
static int rz_dmac_parse_of_icu(struct device *dev, struct rz_dmac *dmac)
858865
{
859866
struct device_node *np = dev->of_node;
@@ -876,6 +883,10 @@ static int rz_dmac_parse_of_icu(struct device *dev, struct rz_dmac *dmac)
876883
return -ENODEV;
877884
}
878885

886+
ret = devm_add_action_or_reset(dev, rz_dmac_put_device, &dmac->icu.pdev->dev);
887+
if (ret)
888+
return ret;
889+
879890
dmac_index = args.args[0];
880891
if (dmac_index > RZV2H_MAX_DMAC_INDEX) {
881892
dev_err(dev, "DMAC index %u invalid.\n", dmac_index);
@@ -1055,8 +1066,6 @@ static void rz_dmac_remove(struct platform_device *pdev)
10551066
reset_control_assert(dmac->rstc);
10561067
pm_runtime_put(&pdev->dev);
10571068
pm_runtime_disable(&pdev->dev);
1058-
1059-
platform_device_put(dmac->icu.pdev);
10601069
}
10611070

10621071
static const struct of_device_id of_rz_dmac_match[] = {

0 commit comments

Comments
 (0)