ASoC: qdsp6v2: prevent null pointer dereference for _vol_cmds

In case of memory allocation failure, _vol_cmd_cnt is not reset.
In _volume_cmds_free, null pointer dereference would happen for
_vol_cmds[i].
To prevent it, reset _vol_cmd_cnt when memory allocation fails.

CRs-Fixed: 1089598
Change-Id: Icb998549cdb999c6db2fd52aef505f200e630da5
Signed-off-by: Xiaojun Sang <xsang@codeaurora.org>
This commit is contained in:
Xiaojun Sang 2016-11-16 15:10:20 +08:00 committed by Shreyas Narayan
parent 29f346365d
commit 5e9c8dba56

View file

@ -236,7 +236,8 @@ static s32 _volume_cmds_alloc1(s32 size)
if (_vol_cmds) {
_vol_cmds_d = kzalloc(_vol_cmd_cnt * sizeof(struct vol_cmds_d),
GFP_KERNEL);
}
} else
_vol_cmd_cnt = 0;
if (_vol_cmds_d)
return 0;
_volume_cmds_free();