]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ASoC: pcm: fix error handling when try_module_get() fails.
authorRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Mon, 8 Apr 2019 19:30:25 +0000 (12:30 -0700)
committerMark Brown <broonie@kernel.org>
Wed, 10 Apr 2019 11:28:00 +0000 (12:28 +0100)
Handle error before returning when try_module_get() fails
to prevent inconsistent mutex lock/unlock.

Fixes: d66bc6390 (ASoC: pcm: update module refcount if
  module_get_upon_open is set)
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/soc-pcm.c

index d21247546f7f7699e3833035c36a5393aff13d67..be80a12fba27cc381b0438a95bb4987c6843cb39 100644 (file)
@@ -518,8 +518,10 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
                        continue;
 
                if (component->driver->module_get_upon_open &&
-                   !try_module_get(component->dev->driver->owner))
-                       return -ENODEV;
+                   !try_module_get(component->dev->driver->owner)) {
+                       ret = -ENODEV;
+                       goto module_err;
+               }
 
                ret = component->driver->ops->open(substream);
                if (ret < 0) {
@@ -636,7 +638,7 @@ codec_dai_err:
 
 component_err:
        soc_pcm_components_close(substream, component);
-
+module_err:
        if (cpu_dai->driver->ops->shutdown)
                cpu_dai->driver->ops->shutdown(substream, cpu_dai);
 out: