From: Pierre-Louis Bossart Date: Mon, 7 Jun 2021 22:22:25 +0000 (-0500) Subject: ASoC: max98373-sdw: add missing memory allocation check X-Git-Tag: v5.14-rc1~95^2~9^2~2^2~27 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=468a272ca49cc4e2f58f3c360643c3f6d313c146;p=thirdparty%2Fkernel%2Flinux.git ASoC: max98373-sdw: add missing memory allocation check We forgot to test that devm_kcalloc doesn't return NULL. Fixes: 349dd23931d1 ('ASoC: max98373: don't access volatile registers in bias level off') Signed-off-by: Pierre-Louis Bossart Reviewed-by: Guennadi Liakhovetski Reviewed-by: Bard Liao Link: https://lore.kernel.org/r/20210607222239.582139-2-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- diff --git a/sound/soc/codecs/max98373-sdw.c b/sound/soc/codecs/max98373-sdw.c index d8c47667a9ea2..e178fdb6b8993 100644 --- a/sound/soc/codecs/max98373-sdw.c +++ b/sound/soc/codecs/max98373-sdw.c @@ -786,6 +786,8 @@ static int max98373_init(struct sdw_slave *slave, struct regmap *regmap) max98373->cache = devm_kcalloc(dev, max98373->cache_num, sizeof(*max98373->cache), GFP_KERNEL); + if (!max98373->cache) + return -ENOMEM; for (i = 0; i < max98373->cache_num; i++) max98373->cache[i].reg = max98373_sdw_cache_reg[i];