Linux-mediatek Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] soc: mediatek: mtk-svs: fix device leaks on probe failure
@ 2025-09-09  9:56 Johan Hovold
  2025-09-09  9:56 ` [PATCH 1/2] soc: mediatek: mtk-svs: fix device leaks on mt8183 " Johan Hovold
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Johan Hovold @ 2025-09-09  9:56 UTC (permalink / raw)
  To: Matthias Brugger, AngeloGioacchino Del Regno
  Cc: Roger Lu, linux-mediatek, linux-kernel, Johan Hovold

This series fixes mostly benign device leaks in case the svs driver
probe defers (or is ever unbound), but which should be fixed if only to
reduce the risk of such bugs being reproduced in places where it matter
more.

Johan


Johan Hovold (2):
  soc: mediatek: mtk-svs: fix device leaks on mt8183 probe failure
  soc: mediatek: mtk-svs: fix device leaks on mt8192 probe failure

 drivers/soc/mediatek/mtk-svs.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

-- 
2.49.1



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

* [PATCH 1/2] soc: mediatek: mtk-svs: fix device leaks on mt8183 probe failure
  2025-09-09  9:56 [PATCH 0/2] soc: mediatek: mtk-svs: fix device leaks on probe failure Johan Hovold
@ 2025-09-09  9:56 ` Johan Hovold
  2025-09-09 11:01   ` AngeloGioacchino Del Regno
  2025-09-09  9:56 ` [PATCH 2/2] soc: mediatek: mtk-svs: fix device leaks on mt8192 " Johan Hovold
  2025-09-10  9:51 ` [PATCH 0/2] soc: mediatek: mtk-svs: fix device leaks on " Matthias Brugger
  2 siblings, 1 reply; 6+ messages in thread
From: Johan Hovold @ 2025-09-09  9:56 UTC (permalink / raw)
  To: Matthias Brugger, AngeloGioacchino Del Regno
  Cc: Roger Lu, linux-mediatek, linux-kernel, Johan Hovold

Make sure to drop the references taken by of_find_device_by_node() when
looking up the thermal sensor and opp devices during probe on probe
failure (e.g. probe deferral) and on driver unbind.

Fixes: 681a02e95000 ("soc: mediatek: SVS: introduce MTK SVS engine")
Cc: Roger Lu <roger.lu@mediatek.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/soc/mediatek/mtk-svs.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c
index 7c349a94b45c..48804e1e5a6c 100644
--- a/drivers/soc/mediatek/mtk-svs.c
+++ b/drivers/soc/mediatek/mtk-svs.c
@@ -2165,6 +2165,13 @@ static struct device *svs_add_device_link(struct svs_platform *svsp,
 	return dev;
 }
 
+static void svs_put_device(void *_dev)
+{
+	struct device *dev = _dev;
+
+	put_device(dev);
+}
+
 static int svs_mt8192_platform_probe(struct svs_platform *svsp)
 {
 	struct device *dev;
@@ -2216,11 +2223,13 @@ static int svs_mt8183_platform_probe(struct svs_platform *svsp)
 {
 	struct device *dev;
 	u32 idx;
+	int ret;
 
 	dev = svs_add_device_link(svsp, "thermal-sensor");
 	if (IS_ERR(dev))
 		return dev_err_probe(svsp->dev, PTR_ERR(dev),
 				     "failed to get thermal device\n");
+	put_device(dev);
 
 	for (idx = 0; idx < svsp->bank_max; idx++) {
 		struct svs_bank *svsb = &svsp->banks[idx];
@@ -2230,6 +2239,7 @@ static int svs_mt8183_platform_probe(struct svs_platform *svsp)
 		case SVSB_SWID_CPU_LITTLE:
 		case SVSB_SWID_CPU_BIG:
 			svsb->opp_dev = get_cpu_device(bdata->cpu_id);
+			get_device(svsb->opp_dev);
 			break;
 		case SVSB_SWID_CCI:
 			svsb->opp_dev = svs_add_device_link(svsp, "cci");
@@ -2246,6 +2256,11 @@ static int svs_mt8183_platform_probe(struct svs_platform *svsp)
 			return dev_err_probe(svsp->dev, PTR_ERR(svsb->opp_dev),
 					     "failed to get OPP device for bank %d\n",
 					     idx);
+
+		ret = devm_add_action_or_reset(svsp->dev, svs_put_device,
+					       svsb->opp_dev);
+		if (ret)
+			return ret;
 	}
 
 	return 0;
-- 
2.49.1



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

* [PATCH 2/2] soc: mediatek: mtk-svs: fix device leaks on mt8192 probe failure
  2025-09-09  9:56 [PATCH 0/2] soc: mediatek: mtk-svs: fix device leaks on probe failure Johan Hovold
  2025-09-09  9:56 ` [PATCH 1/2] soc: mediatek: mtk-svs: fix device leaks on mt8183 " Johan Hovold
@ 2025-09-09  9:56 ` Johan Hovold
  2025-09-09 11:01   ` AngeloGioacchino Del Regno
  2025-09-10  9:51 ` [PATCH 0/2] soc: mediatek: mtk-svs: fix device leaks on " Matthias Brugger
  2 siblings, 1 reply; 6+ messages in thread
From: Johan Hovold @ 2025-09-09  9:56 UTC (permalink / raw)
  To: Matthias Brugger, AngeloGioacchino Del Regno
  Cc: Roger Lu, linux-mediatek, linux-kernel, Johan Hovold

Make sure to drop the references taken by of_find_device_by_node() when
looking up the thermal sensor and opp devices during probe on probe
failure (e.g. probe deferral) and on driver unbind.

Fixes: 0bbb09b2af9d ("soc: mediatek: SVS: add mt8192 SVS GPU driver")
Cc: Roger Lu <roger.lu@mediatek.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/soc/mediatek/mtk-svs.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c
index 48804e1e5a6c..f45537546553 100644
--- a/drivers/soc/mediatek/mtk-svs.c
+++ b/drivers/soc/mediatek/mtk-svs.c
@@ -2176,6 +2176,7 @@ static int svs_mt8192_platform_probe(struct svs_platform *svsp)
 {
 	struct device *dev;
 	u32 idx;
+	int ret;
 
 	svsp->rst = devm_reset_control_get_optional(svsp->dev, "svs_rst");
 	if (IS_ERR(svsp->rst))
@@ -2186,6 +2187,7 @@ static int svs_mt8192_platform_probe(struct svs_platform *svsp)
 	if (IS_ERR(dev))
 		return dev_err_probe(svsp->dev, PTR_ERR(dev),
 				     "failed to get lvts device\n");
+	put_device(dev);
 
 	for (idx = 0; idx < svsp->bank_max; idx++) {
 		struct svs_bank *svsb = &svsp->banks[idx];
@@ -2195,6 +2197,7 @@ static int svs_mt8192_platform_probe(struct svs_platform *svsp)
 		case SVSB_SWID_CPU_LITTLE:
 		case SVSB_SWID_CPU_BIG:
 			svsb->opp_dev = get_cpu_device(bdata->cpu_id);
+			get_device(svsb->opp_dev);
 			break;
 		case SVSB_SWID_CCI:
 			svsb->opp_dev = svs_add_device_link(svsp, "cci");
@@ -2214,6 +2217,11 @@ static int svs_mt8192_platform_probe(struct svs_platform *svsp)
 			return dev_err_probe(svsp->dev, PTR_ERR(svsb->opp_dev),
 					     "failed to get OPP device for bank %d\n",
 					     idx);
+
+		ret = devm_add_action_or_reset(svsp->dev, svs_put_device,
+					       svsb->opp_dev);
+		if (ret)
+			return ret;
 	}
 
 	return 0;
-- 
2.49.1



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

* Re: [PATCH 2/2] soc: mediatek: mtk-svs: fix device leaks on mt8192 probe failure
  2025-09-09  9:56 ` [PATCH 2/2] soc: mediatek: mtk-svs: fix device leaks on mt8192 " Johan Hovold
@ 2025-09-09 11:01   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 6+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-09-09 11:01 UTC (permalink / raw)
  To: Johan Hovold, Matthias Brugger; +Cc: Roger Lu, linux-mediatek, linux-kernel

Il 09/09/25 11:56, Johan Hovold ha scritto:
> Make sure to drop the references taken by of_find_device_by_node() when
> looking up the thermal sensor and opp devices during probe on probe
> failure (e.g. probe deferral) and on driver unbind.
> 
> Fixes: 0bbb09b2af9d ("soc: mediatek: SVS: add mt8192 SVS GPU driver")
> Cc: Roger Lu <roger.lu@mediatek.com>
> Signed-off-by: Johan Hovold <johan@kernel.org>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>




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

* Re: [PATCH 1/2] soc: mediatek: mtk-svs: fix device leaks on mt8183 probe failure
  2025-09-09  9:56 ` [PATCH 1/2] soc: mediatek: mtk-svs: fix device leaks on mt8183 " Johan Hovold
@ 2025-09-09 11:01   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 6+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-09-09 11:01 UTC (permalink / raw)
  To: Johan Hovold, Matthias Brugger; +Cc: Roger Lu, linux-mediatek, linux-kernel

Il 09/09/25 11:56, Johan Hovold ha scritto:
> Make sure to drop the references taken by of_find_device_by_node() when
> looking up the thermal sensor and opp devices during probe on probe
> failure (e.g. probe deferral) and on driver unbind.
> 
> Fixes: 681a02e95000 ("soc: mediatek: SVS: introduce MTK SVS engine")
> Cc: Roger Lu <roger.lu@mediatek.com>
> Signed-off-by: Johan Hovold <johan@kernel.org>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>




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

* Re: [PATCH 0/2] soc: mediatek: mtk-svs: fix device leaks on probe failure
  2025-09-09  9:56 [PATCH 0/2] soc: mediatek: mtk-svs: fix device leaks on probe failure Johan Hovold
  2025-09-09  9:56 ` [PATCH 1/2] soc: mediatek: mtk-svs: fix device leaks on mt8183 " Johan Hovold
  2025-09-09  9:56 ` [PATCH 2/2] soc: mediatek: mtk-svs: fix device leaks on mt8192 " Johan Hovold
@ 2025-09-10  9:51 ` Matthias Brugger
  2 siblings, 0 replies; 6+ messages in thread
From: Matthias Brugger @ 2025-09-10  9:51 UTC (permalink / raw)
  To: Johan Hovold, AngeloGioacchino Del Regno
  Cc: Roger Lu, linux-mediatek, linux-kernel



On 09/09/2025 11:56, Johan Hovold wrote:
> This series fixes mostly benign device leaks in case the svs driver
> probe defers (or is ever unbound), but which should be fixed if only to
> reduce the risk of such bugs being reproduced in places where it matter
> more.
> 

Series queued, thanks!

> Johan
> 
> 
> Johan Hovold (2):
>    soc: mediatek: mtk-svs: fix device leaks on mt8183 probe failure
>    soc: mediatek: mtk-svs: fix device leaks on mt8192 probe failure
> 
>   drivers/soc/mediatek/mtk-svs.c | 23 +++++++++++++++++++++++
>   1 file changed, 23 insertions(+)
> 



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

end of thread, other threads:[~2025-09-10  9:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-09  9:56 [PATCH 0/2] soc: mediatek: mtk-svs: fix device leaks on probe failure Johan Hovold
2025-09-09  9:56 ` [PATCH 1/2] soc: mediatek: mtk-svs: fix device leaks on mt8183 " Johan Hovold
2025-09-09 11:01   ` AngeloGioacchino Del Regno
2025-09-09  9:56 ` [PATCH 2/2] soc: mediatek: mtk-svs: fix device leaks on mt8192 " Johan Hovold
2025-09-09 11:01   ` AngeloGioacchino Del Regno
2025-09-10  9:51 ` [PATCH 0/2] soc: mediatek: mtk-svs: fix device leaks on " Matthias Brugger

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