From: Johan Hovold Date: Wed, 26 Nov 2025 14:53:26 +0000 (+0100) Subject: slimbus: core: fix device reference leak on report present X-Git-Tag: v6.6.122~51 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2ddc09f6a0a221b1d91a7cbc8cc2cefdbd334fe6;p=thirdparty%2Fkernel%2Fstable.git slimbus: core: fix device reference leak on report present commit 9391380eb91ea5ac792aae9273535c8da5b9aa01 upstream. Slimbus devices can be allocated dynamically upon reception of report-present messages. Make sure to drop the reference taken when looking up already registered devices. Note that this requires taking an extra reference in case the device has not yet been registered and has to be allocated. Fixes: 46a2bb5a7f7e ("slimbus: core: Add slim controllers support") Cc: stable@vger.kernel.org # 4.16 Signed-off-by: Johan Hovold Link: https://patch.msgid.link/20251126145329.5022-4-johan@kernel.org Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/slimbus/core.c b/drivers/slimbus/core.c index ef3f2a530750..fdc099abd2cc 100644 --- a/drivers/slimbus/core.c +++ b/drivers/slimbus/core.c @@ -378,6 +378,8 @@ struct slim_device *slim_get_device(struct slim_controller *ctrl, sbdev = slim_alloc_device(ctrl, e_addr, NULL); if (!sbdev) return ERR_PTR(-ENOMEM); + + get_device(&sbdev->dev); } return sbdev; @@ -512,6 +514,7 @@ int slim_device_report_present(struct slim_controller *ctrl, ret = slim_device_alloc_laddr(sbdev, true); } + put_device(&sbdev->dev); out_put_rpm: pm_runtime_mark_last_busy(ctrl->dev); pm_runtime_put_autosuspend(ctrl->dev);