未验证 提交 52034add 编写于 作者: R Ranjani Sridharan 提交者: Mark Brown

ASoC: pcm: update module refcount if module_get_upon_open is set

Setting the module_get_upon_open field for component driver
prevents the module refcount from being incremented during
component probe(). This could lead to the module being
allowed to be unloaded when a pcm stream is open. So,
if this field is set, the module's refcount should be
incremented during pcm open to prevent module removal
when the component is in use. And, the refcount should
be decremented upon pcm close.
Signed-off-by: NRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Acked-by: NPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: NMark Brown <broonie@kernel.org>
上级 b4ed6b51
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/pinctrl/consumer.h> #include <linux/pinctrl/consumer.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/module.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/export.h> #include <linux/export.h>
...@@ -463,6 +464,9 @@ static int soc_pcm_components_close(struct snd_pcm_substream *substream, ...@@ -463,6 +464,9 @@ static int soc_pcm_components_close(struct snd_pcm_substream *substream,
continue; continue;
component->driver->ops->close(substream); component->driver->ops->close(substream);
if (component->driver->module_get_upon_open)
module_put(component->dev->driver->owner);
} }
return 0; return 0;
...@@ -513,6 +517,10 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) ...@@ -513,6 +517,10 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
!component->driver->ops->open) !component->driver->ops->open)
continue; continue;
if (component->driver->module_get_upon_open &&
!try_module_get(component->dev->driver->owner))
return -ENODEV;
ret = component->driver->ops->open(substream); ret = component->driver->ops->open(substream);
if (ret < 0) { if (ret < 0) {
dev_err(component->dev, dev_err(component->dev,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册