Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soc: amlogic: canvas: fix device leak on lookup

Make sure to drop the reference taken to the canvas 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.

Also note that commit 28f851e6afa8 ("soc: amlogic: canvas: add missing
put_device() call in meson_canvas_get()") fixed the leak in a lookup
error path, but the reference is still leaking on success.

Fixes: d4983983d987 ("soc: amlogic: add meson-canvas driver")
Cc: stable@vger.kernel.org # 4.20: 28f851e6afa8
Cc: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Link: https://patch.msgid.link/20250926142454.5929-2-johan@kernel.org
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>

authored by

Johan Hovold and committed by
Neil Armstrong
32200f48 3a866087

+2 -3
+2 -3
drivers/soc/amlogic/meson-canvas.c
··· 73 73 * current state, this driver probe cannot return -EPROBE_DEFER 74 74 */ 75 75 canvas = dev_get_drvdata(&canvas_pdev->dev); 76 - if (!canvas) { 77 - put_device(&canvas_pdev->dev); 76 + put_device(&canvas_pdev->dev); 77 + if (!canvas) 78 78 return ERR_PTR(-EINVAL); 79 - } 80 79 81 80 return canvas; 82 81 }