ASoC: rsnd: check for zero node count
authorColin Ian King <colin.king@canonical.com>
Thu, 3 Jun 2021 11:03:15 +0000 (12:03 +0100)
committerMark Brown <broonie@kernel.org>
Thu, 3 Jun 2021 12:59:59 +0000 (13:59 +0100)
Most callers of_get_child_count() check that "nr" is non-zero so it
causes a static checker warning when we don't do that here.  This
does not cause a problem or a crash, but having zero SSUIes does not
make sense either so let's add a check.

Addresses-Coverity: ("Unchecked return value")
Fixes: c413983eb66a ("ASoC: rsnd: adjust disabled module")
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20210603110315.81146-1-colin.king@canonical.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sh/rcar/ssiu.c

index 5682c74..0d8f976 100644 (file)
@@ -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;