public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: c8sectpfe: fix probe device leaks
@ 2025-09-23 15:16 Johan Hovold
  2025-10-27 13:35 ` Johan Hovold
  0 siblings, 1 reply; 5+ messages in thread
From: Johan Hovold @ 2025-09-23 15:16 UTC (permalink / raw)
  To: Patrice Chotard, Mauro Carvalho Chehab
  Cc: linux-media, linux-kernel, Johan Hovold, stable, Peter Griffin

Make sure to drop the references taken to the I2C adapters during probe
on probe failure (e.g. probe deferral) and on driver unbind.

Fixes: c5f5d0f99794 ("[media] c8sectpfe: STiH407/10 Linux DVB demux support")
Cc: stable@vger.kernel.org	# 4.3
Cc: Peter Griffin <peter.griffin@linaro.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 .../media/platform/st/sti/c8sectpfe/c8sectpfe-core.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c b/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c
index 89bd15a4d26a..3f94d9b4ef1e 100644
--- a/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c
+++ b/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c
@@ -655,6 +655,13 @@ static irqreturn_t c8sectpfe_error_irq_handler(int irq, void *priv)
 	return IRQ_HANDLED;
 }
 
+static void c8sectpfe_put_device(void *_dev)
+{
+	struct device *dev = _dev;
+
+	put_device(dev);
+}
+
 static int c8sectpfe_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -799,6 +806,11 @@ static int c8sectpfe_probe(struct platform_device *pdev)
 			return -ENODEV;
 		}
 
+		ret = devm_add_action_or_reset(dev, c8sectpfe_put_device,
+					       &tsin->i2c_adapter->dev);
+		if (ret)
+			return ret;
+
 		/* Acquire reset GPIO and activate it */
 		tsin->rst_gpio = devm_fwnode_gpiod_get(dev,
 						       of_fwnode_handle(child),
-- 
2.49.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-10-27 15:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-23 15:16 [PATCH] media: c8sectpfe: fix probe device leaks Johan Hovold
2025-10-27 13:35 ` Johan Hovold
2025-10-27 14:28   ` Patrice CHOTARD
2025-10-27 15:10     ` Peter Griffin
2025-10-27 15:35     ` Johan Hovold

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox