ASoC: soc-cache: Fix the return value of snd_soc_cache_init when reg_size is 0
diff mbox

Message ID 1401719034-17204-1-git-send-email-fabio.estevam@freescale.com
State Accepted
Commit b5fc40d3b37bdb3524cdf1f550bd0c3b05ac3888
Headers show

Commit Message

Fabio Estevam June 2, 2014, 2:23 p.m. UTC
Commit b59dce53ef6 (ASoC: cache: Fix possible ZERO_SIZE_PTR pointer 
dereferencing error.) caused the following probe error:

wm8962 0-001a: customer id 0 revision D
wm8962 0-001a: ASoC: Failed to set cache compression type: -22
imx-wm8962 sound: snd_soc_register_card failed (-22)
imx-wm8962: probe of sound failed with error -22

If reg_size just return success instead.

Suggested-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 sound/soc/soc-cache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Mark Brown June 2, 2014, 4:17 p.m. UTC | #1
On Mon, Jun 02, 2014 at 11:23:54AM -0300, Fabio Estevam wrote:
> Commit b59dce53ef6 (ASoC: cache: Fix possible ZERO_SIZE_PTR pointer 
> dereferencing error.) caused the following probe error:
> 
> wm8962 0-001a: customer id 0 revision D
> wm8962 0-001a: ASoC: Failed to set cache compression type: -22
> imx-wm8962 sound: snd_soc_register_card failed (-22)
> imx-wm8962: probe of sound failed with error -22

Thanks - I already wrote a patch for this before I saw this one, sorry.

Patch
diff mbox

diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c
index 8fff5b6..00e70b6 100644
--- a/sound/soc/soc-cache.c
+++ b/sound/soc/soc-cache.c
@@ -73,7 +73,7 @@  int snd_soc_cache_init(struct snd_soc_codec *codec)
 	reg_size = codec_drv->reg_cache_size * codec_drv->reg_word_size;
 
 	if (!reg_size)
-		return -EINVAL;
+		return 0;
 
 	mutex_init(&codec->cache_rw_mutex);