ASoC: SOF: sof-client-probes: fix pm_runtime imbalance in error handling
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Fri, 12 May 2023 10:33:15 +0000 (13:33 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 9 Jun 2023 08:34:13 +0000 (10:34 +0200)
[ Upstream commit bc424273c74c1565c459c8f2a6ed95caee368d0a ]

When an error occurs, we need to make sure the device can pm_runtime
suspend instead of keeping it active.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com
Link: https://lore.kernel.org/r/20230512103315.8921-4-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/soc/sof/sof-client-probes.c

index ddeabbb..1e521a9 100644 (file)
@@ -441,12 +441,7 @@ static ssize_t sof_probes_dfs_points_read(struct file *file, char __user *to,
 
        ret = sof_probes_points_info(cdev, &desc, &num_desc);
        if (ret < 0)
-               goto exit;
-
-       pm_runtime_mark_last_busy(dev);
-       err = pm_runtime_put_autosuspend(dev);
-       if (err < 0)
-               dev_err_ratelimited(dev, "debugfs read failed to idle %d\n", err);
+               goto pm_error;
 
        for (i = 0; i < num_desc; i++) {
                offset = strlen(buf);
@@ -464,6 +459,13 @@ static ssize_t sof_probes_dfs_points_read(struct file *file, char __user *to,
        ret = simple_read_from_buffer(to, count, ppos, buf, strlen(buf));
 
        kfree(desc);
+
+pm_error:
+       pm_runtime_mark_last_busy(dev);
+       err = pm_runtime_put_autosuspend(dev);
+       if (err < 0)
+               dev_err_ratelimited(dev, "debugfs read failed to idle %d\n", err);
+
 exit:
        kfree(buf);
        return ret;