From b0219ff89b45b93a58219cc72e7d63fac66ca40a Mon Sep 17 00:00:00 2001 From: guoyf2 Date: Fri, 30 Nov 2018 17:56:53 +0800 Subject: [PATCH] fix tfa NULL ptr memory exception For "NXP Volume" and "NXP mode" mixer, we need to increase nr_controls. Change-Id: I93e8a8d62908d8c8681fa10ff7efc3e96922b996 Signed-off-by: guoyf2 Reviewed-on: https://gerrit.mot.com/1276325 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Yunfei Guo Reviewed-by: Xiangpo Zhao Reviewed-by: Jianguo Liu Reviewed-by: Wanlong Zhou Submit-Approved: Jira Key --- sound/soc/codecs/tfa98xx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/tfa98xx.c b/sound/soc/codecs/tfa98xx.c index f7ef4e6a0cbb..a4d6b6c3722c 100644 --- a/sound/soc/codecs/tfa98xx.c +++ b/sound/soc/codecs/tfa98xx.c @@ -1684,7 +1684,9 @@ static int tfa98xx_create_controls(struct tfa98xx *tfa98xx) #ifdef TFA9874_NONDSP_STEREO nr_controls += 1; /* for TFA_CHIP_SELECTOR */ + nr_controls += 1; /* for NXP Volume */ #endif + nr_controls += 1; /* for NXP Mode */ /* allocate the tfa98xx_controls base on the nr of profiles */ nprof = tfa_cnt_get_dev_nprof(tfa98xx->tfa); @@ -1695,7 +1697,7 @@ static int tfa98xx_create_controls(struct tfa98xx *tfa98xx) tfa98xx_controls = devm_kzalloc(tfa98xx->codec->dev, nr_controls * sizeof(tfa98xx_controls[0]), GFP_KERNEL); - if (!tfa98xx_controls) + if (!tfa98xx_controls) return -ENOMEM; /* Create a mixer item for selecting the active profile */