ASoC: rsnd: check src mod pointer for rsnd_mod_id()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Wed, 17 May 2017 06:50:32 +0000 (06:50 +0000)
committerMark Brown <broonie@kernel.org>
Wed, 17 May 2017 09:30:47 +0000 (10:30 +0100)
Without this patch, gcc 4.9.x says

    sound/soc/sh/rcar/cmd.c: In function 'rsnd_cmd_init':
    sound/soc/sh/rcar/cmd.c:85:14: warning: array subscript is below array\
bounds [-Warray-bounds]
data = path[rsnd_mod_id(src)] |

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sh/rcar/cmd.c

index 7d92a24b7cfa558afbb8331401c974c59d5f1ae5..98835e9d1d7d13ddc905917a34419e61add7cc83 100644 (file)
@@ -82,6 +82,9 @@ static int rsnd_cmd_init(struct rsnd_mod *mod,
                        [9] = 0x2,
                };
 
+               if (unlikely(!src))
+                       return -EIO;
+
                data = path[rsnd_mod_id(src)] |
                        cmd_case[rsnd_mod_id(src)] << 16;
        }