All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: max98373: Add checks for devm_kcalloc
@ 2022-11-16  8:25 ` Jiasheng Jiang
  0 siblings, 0 replies; 3+ messages in thread
From: Jiasheng Jiang @ 2022-11-16  8:25 UTC (permalink / raw)
  To: lgirdwood, broonie, perex, tiwai, ryan.lee.analog, steve,
	pierre-louis.bossart
  Cc: alsa-devel, Jiasheng Jiang, linux-kernel

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@iscas.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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] ASoC: max98373: Add checks for devm_kcalloc
@ 2022-11-16  8:25 ` Jiasheng Jiang
  0 siblings, 0 replies; 3+ messages in thread
From: Jiasheng Jiang @ 2022-11-16  8:25 UTC (permalink / raw)
  To: lgirdwood, broonie, perex, tiwai, ryan.lee.analog, steve,
	pierre-louis.bossart
  Cc: alsa-devel, linux-kernel, Jiasheng Jiang

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@iscas.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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ASoC: max98373: Add checks for devm_kcalloc
  2022-11-16  8:25 ` Jiasheng Jiang
  (?)
@ 2022-11-16 13:47 ` Mark Brown
  -1 siblings, 0 replies; 3+ messages in thread
From: Mark Brown @ 2022-11-16 13:47 UTC (permalink / raw)
  To: pierre-louis.bossart, Jiasheng Jiang, steve, lgirdwood,
	ryan.lee.analog, perex, tiwai
  Cc: alsa-devel, linux-kernel

On Wed, 16 Nov 2022 16:25:08 +0800, Jiasheng Jiang wrote:
> As the devm_kcalloc may return NULL pointer,
> it should be better to check the return value
> in order to avoid NULL poineter dereference.
> 
> 

Applied to

   broonie/sound.git for-next

Thanks!

[1/1] ASoC: max98373: Add checks for devm_kcalloc
      commit: 60591bbf6d5eb44f275eb733943b7757325c1b60

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-16 13:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-16  8:25 [PATCH] ASoC: max98373: Add checks for devm_kcalloc Jiasheng Jiang
2022-11-16  8:25 ` Jiasheng Jiang
2022-11-16 13:47 ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.