Skip to contentSkip to conversation

ASoC: ti: davinci-mcasp: Fix runtime PM imbalance in __davinci_mcasp_set_clkdiv()

PATCH In review Wentao Liang 4 participants 4 messages Sep 16 – Sep 23

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: ti: davinci-mcasp: Fix runtime PM imbalance in __davinci_mcasp_set_clkdiv()

In __davinci_mcasp_set_clkdiv(), pm_runtime_get_sync() is called at the entry of the function. If an invalid div_id is provided, the function hits the default switch case and directly returns -EINVAL without calling pm_runtime_put(), resulting in a runtime PM reference leak.

Add pm_runtime_put() in the default case before returning -EINVAL.

Fixes 4ed8c9b737b6 ("ASoC: McASP: add support for clock dividers")
---
 sound/soc/ti/davinci-mcasp.c | 1 +
 1 file changed, 1 insertion(+)
sound/soc/ti/davinci-mcasp.c +1 -0
index f229f847eaf4..1ec42fe02fc8 100644
@@ -786,6 +786,7 @@ static int __davinci_mcasp_set_clkdiv(struct davinci_mcasp *mcasp, int div_id,
 		break;
 
 	default:
+		pm_runtime_put(mcasp->dev);
 		return -EINVAL;
 	}
 
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 5 lines · Wentao Liang

In __davinci_mcasp_set_clkdiv(), pm_runtime_get_sync() is called at the entry of the function. If an invalid div_id is provided, the function hits the default switch case and directly returns -EINVAL without calling pm_runtime_put(), resulting in a runtime PM reference leak.

Quoted 8 lines

Add pm_runtime_put() in the default case before returning -EINVAL.

Fixes 4ed8c9b737b6 ("ASoC: McASP: add support for clock dividers")
---
 sound/soc/ti/davinci-mcasp.c | 1 +
 1 file changed, 1 insertion(+)

Did you forget an "Assisted-by:" tag for all of these submissions? If so, please fix up and send new ones.

thanks,

greg k-h

maintainer Tested-by on v1 1/1
#2 lore raw
In reply to Wentao Liang
Quoted 10 lines · Wentao Liang

In __davinci_mcasp_set_clkdiv(), pm_runtime_get_sync() is called at the entry of the function. If an invalid div_id is provided, the function hits the default switch case and directly returns -EINVAL without calling pm_runtime_put(), resulting in a runtime PM reference leak.

Add pm_runtime_put() in the default case before returning -EINVAL.

Fixes 4ed8c9b737b6 ("ASoC: McASP: add support for clock dividers")

Hi Wentao, thanks for the catch!

Manual runtime PM reference is quite tedious and results in reference leak like you've pinpointed, maybe it's better to convert to a guard()/ACQUIRE() based approach in the future...

Assuming you took Greg's input if you need to submit a V2:

maintainer
#3 lore raw
In reply to Wentao Liang
Quoted 1 line · Wentao Liang

ASoC: ti: davinci-mcasp: Fix runtime PM imbalance in __davinci_mcasp_set_clkdiv()

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.4

Thanks!

[1/1] ASoC: ti: davinci-mcasp: Fix runtime PM imbalance in __davinci_mcasp_set_clkdiv()

      https://git.kernel.org/broonie/sound/c/ba593d662183

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark