Skip to content

Commit 25073a0

Browse files
jhovoldgregkh
authored andcommitted
soc: apple: mailbox: fix device leak on lookup
commit f401671 upstream. Make sure to drop the reference taken to the mbox platform device when looking up its driver data. Note that holding a reference to a device does not prevent its driver data from going away so there is no point in keeping the reference. Fixes: 6e1457f ("soc: apple: mailbox: Add ASC/M3 mailbox driver") Cc: stable@vger.kernel.org # 6.8 Signed-off-by: Johan Hovold <johan@kernel.org> Reviewed-by: Neal Gompa <neal@gompa.dev> Signed-off-by: Sven Peter <sven@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b28fd17 commit 25073a0

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

drivers/soc/apple/mailbox.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,18 @@ struct apple_mbox *apple_mbox_get(struct device *dev, int index)
302302
return ERR_PTR(-EPROBE_DEFER);
303303

304304
mbox = platform_get_drvdata(pdev);
305-
if (!mbox)
306-
return ERR_PTR(-EPROBE_DEFER);
305+
if (!mbox) {
306+
mbox = ERR_PTR(-EPROBE_DEFER);
307+
goto out_put_pdev;
308+
}
309+
310+
if (!device_link_add(dev, &pdev->dev, DL_FLAG_AUTOREMOVE_CONSUMER)) {
311+
mbox = ERR_PTR(-ENODEV);
312+
goto out_put_pdev;
313+
}
307314

308-
if (!device_link_add(dev, &pdev->dev, DL_FLAG_AUTOREMOVE_CONSUMER))
309-
return ERR_PTR(-ENODEV);
315+
out_put_pdev:
316+
put_device(&pdev->dev);
310317

311318
return mbox;
312319
}

0 commit comments

Comments
 (0)