Skip to content

Commit 9391380

Browse files
jhovoldgregkh
authored andcommitted
slimbus: core: fix device reference leak on report present
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: 46a2bb5 ("slimbus: core: Add slim controllers support") Cc: stable@vger.kernel.org # 4.16 Signed-off-by: Johan Hovold <johan@kernel.org> Link: https://patch.msgid.link/20251126145329.5022-4-johan@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0eb4ff6 commit 9391380

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

drivers/slimbus/core.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,8 @@ struct slim_device *slim_get_device(struct slim_controller *ctrl,
379379
sbdev = slim_alloc_device(ctrl, e_addr, NULL);
380380
if (!sbdev)
381381
return ERR_PTR(-ENOMEM);
382+
383+
get_device(&sbdev->dev);
382384
}
383385

384386
return sbdev;
@@ -505,6 +507,7 @@ int slim_device_report_present(struct slim_controller *ctrl,
505507
ret = slim_device_alloc_laddr(sbdev, true);
506508
}
507509

510+
put_device(&sbdev->dev);
508511
out_put_rpm:
509512
pm_runtime_mark_last_busy(ctrl->dev);
510513
pm_runtime_put_autosuspend(ctrl->dev);

0 commit comments

Comments
 (0)