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

drm/imx/tve: fix probe device leak

Make sure to drop the reference taken to the DDC device during probe on
probe failure (e.g. probe deferral) and on driver unbind.

Fixes: fcbc51e54d2a ("staging: drm/imx: Add support for Television Encoder (TVEv2)")
Cc: stable@vger.kernel.org # 3.10
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://patch.msgid.link/20251030163456.15807-1-johan@kernel.org
Signed-off-by: Maxime Ripard <mripard@kernel.org>

authored by

Johan Hovold and committed by
Maxime Ripard
e535c235 12f15d52

+13
+13
drivers/gpu/drm/imx/ipuv3/imx-tve.c
··· 528 528 .bind = imx_tve_bind, 529 529 }; 530 530 531 + static void imx_tve_put_device(void *_dev) 532 + { 533 + struct device *dev = _dev; 534 + 535 + put_device(dev); 536 + } 537 + 531 538 static int imx_tve_probe(struct platform_device *pdev) 532 539 { 533 540 struct device *dev = &pdev->dev; ··· 556 549 if (ddc_node) { 557 550 tve->ddc = of_find_i2c_adapter_by_node(ddc_node); 558 551 of_node_put(ddc_node); 552 + if (tve->ddc) { 553 + ret = devm_add_action_or_reset(dev, imx_tve_put_device, 554 + &tve->ddc->dev); 555 + if (ret) 556 + return ret; 557 + } 559 558 } 560 559 561 560 tve->mode = of_get_tve_mode(np);