[PATCH] soc: mediatek: SVS: Fix a reference leak bug in svs_add_device_link()
Haoxiang Li
haoxiang_li2024 at 163.com
Thu Dec 4 03:04:52 PST 2025
svs_get_subsys_device() increases the reference count of the returned
device, if error happens, put_device() is required to drop the device
reference.
Fixes: 681a02e95000 ("soc: mediatek: SVS: introduce MTK SVS engine")
Cc: stable at vger.kernel.org
Signed-off-by: Haoxiang Li <haoxiang_li2024 at 163.com>
---
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 f45537546553..c8f15bb139c6 100644
--- a/drivers/soc/mediatek/mtk-svs.c
+++ b/drivers/soc/mediatek/mtk-svs.c
@@ -2155,12 +2155,15 @@ static struct device *svs_add_device_link(struct svs_platform *svsp,
sup_link = device_link_add(svsp->dev, dev,
DL_FLAG_AUTOREMOVE_CONSUMER);
if (!sup_link) {
+ put_device(dev);
dev_err(svsp->dev, "sup_link is NULL\n");
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.25.1
More information about the Linux-mediatek
mailing list