ASoC: rsnd: check return value of init function
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Mon, 20 Feb 2017 21:05:07 +0000 (22:05 +0100)
committerMark Brown <broonie@kernel.org>
Tue, 21 Feb 2017 17:51:23 +0000 (09:51 -0800)
Currently, this function cannot fail for the ADG case. Still, let's
apply defensive programming techniques to make sure we fail gracefully
whenever rsnd_mod_init() gets extended with another failure case.
Reported by Coverity (CID 1397893).

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sh/rcar/adg.c

index 85a33ac0a5c443f86159480d9c74d02711cb0c8b..54146f66538c18ba87cfe4a0e4e3c68fb3d880d9 100644 (file)
@@ -564,6 +564,7 @@ int rsnd_adg_probe(struct rsnd_priv *priv)
        struct rsnd_adg *adg;
        struct device *dev = rsnd_priv_to_dev(priv);
        struct device_node *np = dev->of_node;
+       int ret;
 
        adg = devm_kzalloc(dev, sizeof(*adg), GFP_KERNEL);
        if (!adg) {
@@ -571,8 +572,10 @@ int rsnd_adg_probe(struct rsnd_priv *priv)
                return -ENOMEM;
        }
 
-       rsnd_mod_init(priv, &adg->mod, &adg_ops,
+       ret = rsnd_mod_init(priv, &adg->mod, &adg_ops,
                      NULL, NULL, 0, 0);
+       if (ret)
+               return ret;
 
        rsnd_adg_get_clkin(priv, adg);
        rsnd_adg_get_clkout(priv, adg);