lkml.org 
[lkml]   [2021]   [Jun]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH][next] ASoC: rsnd: check for zero node count
Date
From: Colin Ian King <colin.king@canonical.com>

The call to rsnd_node_count can potentially return a zero node count
so add a check for this corner case. (Note that the two other calls
to rsnd_node_count in the kernel perform this check, so I think it
justifies adding this). This avoids using a zero nr in a devm_kcalloc
call.

Addresses-Coverity: ("Unchecked return value")
Fixes: c413983eb66a ("ASoC: rsnd: adjust disabled module")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
sound/soc/sh/rcar/ssiu.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/sound/soc/sh/rcar/ssiu.c b/sound/soc/sh/rcar/ssiu.c
index 5682c74bb7ff..0d8f97633dd2 100644
--- a/sound/soc/sh/rcar/ssiu.c
+++ b/sound/soc/sh/rcar/ssiu.c
@@ -515,6 +515,9 @@ int rsnd_ssiu_probe(struct rsnd_priv *priv)
else
nr = priv->ssi_nr;

+ if (!nr)
+ return -EINVAL;
+
ssiu = devm_kcalloc(dev, nr, sizeof(*ssiu), GFP_KERNEL);
if (!ssiu)
return -ENOMEM;
--
2.31.1
\
 
 \ /
  Last update: 2021-06-02 12:38    [W:0.282 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site