[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221116082508.17418-1-jiasheng@iscas.ac.cn>
Date: Wed, 16 Nov 2022 16:25:08 +0800
From: Jiasheng Jiang <jiasheng@...as.ac.cn>
To: lgirdwood@...il.com, broonie@...nel.org, perex@...ex.cz,
tiwai@...e.com, ryan.lee.analog@...il.com, steve@....org,
pierre-louis.bossart@...ux.intel.com
Cc: alsa-devel@...a-project.org, linux-kernel@...r.kernel.org,
Jiasheng Jiang <jiasheng@...as.ac.cn>
Subject: [PATCH] ASoC: max98373: Add checks for devm_kcalloc
As the devm_kcalloc may return NULL pointer,
it should be better to check the return value
in order to avoid NULL poineter dereference.
Fixes: 349dd23931d1 ("ASoC: max98373: don't access volatile registers in bias level off")
Signed-off-by: Jiasheng Jiang <jiasheng@...as.ac.cn>
---
sound/soc/codecs/max98373-i2c.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/sound/soc/codecs/max98373-i2c.c b/sound/soc/codecs/max98373-i2c.c
index 3e04c7f0cce4..ec0905df65d1 100644
--- a/sound/soc/codecs/max98373-i2c.c
+++ b/sound/soc/codecs/max98373-i2c.c
@@ -549,6 +549,10 @@ static int max98373_i2c_probe(struct i2c_client *i2c)
max98373->cache = devm_kcalloc(&i2c->dev, max98373->cache_num,
sizeof(*max98373->cache),
GFP_KERNEL);
+ if (!max98373->cache) {
+ ret = -ENOMEM;
+ return ret;
+ }
for (i = 0; i < max98373->cache_num; i++)
max98373->cache[i].reg = max98373_i2c_cache_reg[i];
--
2.25.1
Powered by blists - more mailing lists