diff options
author | Michał Orynicz <michal.orynicz@sonymobile.com> | 2016-09-27 13:50:43 +0200 |
---|---|---|
committer | Michał Orynicz <michal.orynicz@sonymobile.com> | 2016-09-27 13:50:43 +0200 |
commit | a900cfa34654db0c463334d3691cf7529a22184c (patch) | |
tree | ee03b4e184ed8b99e5b2f21397b56d0fc5757ba5 | |
parent | 1c157ed9d22933894cd354c85c1f17f57bf4d7c0 (diff) | |
download | bcm-a900cfa34654db0c463334d3691cf7529a22184c.tar.gz |
Validate codec passed to snd_socread/write
There was no validation of the codec variable
passed to the snd_soc_read and snd_soc_write functions.
Add a check for null function pointers in the dummy
sound driver.
Commit based on ANDROID-28838221 snippet.
Change-Id: I6dba002e0123ad36795b5f2537f81a3e9c020b0a
-rw-r--r-- | sound/soc/soc-core.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index d56bbea6e75..b145b91e095 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2103,9 +2103,13 @@ unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg) { unsigned int ret; - ret = codec->read(codec, reg); - dev_dbg(codec->dev, "read %x => %x\n", reg, ret); - trace_snd_soc_reg_read(codec, reg, ret); + if (codec->read) { + ret = codec->read(codec, reg); + dev_dbg(codec->dev, "read %x => %x\n", reg, ret); + trace_snd_soc_reg_read(codec, reg, ret); + } + else + ret = -EIO; return ret; } @@ -2114,9 +2118,13 @@ EXPORT_SYMBOL_GPL(snd_soc_read); unsigned int snd_soc_write(struct snd_soc_codec *codec, unsigned int reg, unsigned int val) { - dev_dbg(codec->dev, "write %x = %x\n", reg, val); - trace_snd_soc_reg_write(codec, reg, val); - return codec->write(codec, reg, val); + if (codec->write) { + dev_dbg(codec->dev, "write %x = %x\n", reg, val); + trace_snd_soc_reg_write(codec, reg, val); + return codec->write(codec, reg, val); + } + else + return -EIO; } EXPORT_SYMBOL_GPL(snd_soc_write); |