[PATCH] soc: mediatek: svs: drop the subsystem device reference on failure

Wentao Liang vulab at iscas.ac.cn
Tue Nov 3 18:14:45 PST 2026


svs_get_subsys_device() returns a device from of_find_device_by_node(),
which takes a reference the caller owns. svs_add_device_link() hands that
reference to its caller on success, but both error paths - a failed
device_link_add() and a supplier that is not bound yet - return an error
pointer without giving it back, so the supplier device can never be
released when probing fails or defers.

Put the reference before returning on both paths. The device link created
on the deferred path is kept on purpose: it is what makes the driver core
retry the consumer once the supplier has probed.

Fixes: 681a02e95000 ("soc: mediatek: SVS: introduce MTK SVS engine")
Cc: stable at vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab at iscas.ac.cn>
---
 drivers/soc/mediatek/mtk-svs.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c
index 99edecb204f2..dd9643026c66 100644
--- a/drivers/soc/mediatek/mtk-svs.c
+++ b/drivers/soc/mediatek/mtk-svs.c
@@ -2155,11 +2155,14 @@ static struct device *svs_add_device_link(struct svs_platform *svsp,
 				   DL_FLAG_AUTOREMOVE_CONSUMER);
 	if (!sup_link) {
 		dev_err(svsp->dev, "sup_link is NULL\n");
+		put_device(dev);
 		return ERR_PTR(-EINVAL);
 	}
 
-	if (sup_link->supplier->links.status != DL_DEV_DRIVER_BOUND)
+	if (sup_link->supplier->links.status != DL_DEV_DRIVER_BOUND) {
+		put_device(dev);
 		return ERR_PTR(-EPROBE_DEFER);
+	}
 
 	return dev;
 }
-- 
2.34.1




More information about the linux-arm-kernel mailing list