Merge tag 'v6.17-next-soc' of https://git.kernel.org/pub/scm/linux/kernel/git/mediatek/linux into soc/drivers
mtk-svs: * Drop reference taken on probe failure * tag 'v6.17-next-soc' of https://git.kernel.org/pub/scm/linux/kernel/git/mediatek/linux: soc: mediatek: mtk-svs: fix device leaks on mt8192 probe failure soc: mediatek: mtk-svs: fix device leaks on mt8183 probe failure Link: https://lore.kernel.org/r/87c8f50b-90a5-47ed-af60-99a4e075a266@gmail.com Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
@@ -2165,10 +2165,18 @@ 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;
|
||||
u32 idx;
|
||||
int ret;
|
||||
|
||||
svsp->rst = devm_reset_control_get_optional(svsp->dev, "svs_rst");
|
||||
if (IS_ERR(svsp->rst))
|
||||
@@ -2179,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];
|
||||
@@ -2188,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");
|
||||
@@ -2207,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;
|
||||
@@ -2216,11 +2231,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 +2247,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 +2264,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;
|
||||
|
||||
Reference in New Issue
Block a user