From: Shuai Li Date: Sun, 28 Apr 2019 13:15:49 +0000 (+0800) Subject: audio: add param check for resample [1/1] X-Git-Tag: khadas-vims-v0.9.6-release~506 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cd7b2b72bfba728c7a0cc01b93e40d821f2f0b73;p=platform%2Fkernel%2Flinux-amlogic.git audio: add param check for resample [1/1] PD#SWPL-7798 Problem: Crashed when audio resample setting params are invalid. Solution: Add check method if the params is invalid. Verify: Tl1. Change-Id: I1e0396be8d401c0a49ff0de9fd7f160f0c8133ca Signed-off-by: Shuai Li --- diff --git a/sound/soc/amlogic/auge/resample.c b/sound/soc/amlogic/auge/resample.c index 7c56eb1..e429f4d 100644 --- a/sound/soc/amlogic/auge/resample.c +++ b/sound/soc/amlogic/auge/resample.c @@ -246,16 +246,22 @@ int resample_set(int id, int index) if (!p_resample) return 0; + if (index < 0 || index > 7) { + pr_err("%s(), invalid index %d\n", __func__, index); + return 0; + } + + pr_info("%s resample_%c to %s, last %s\n", + __func__, + (id == RESAMPLE_A) ? 'a' : 'b', + auge_resample_texts[index], + auge_resample_texts[p_resample->asrc_rate_idx]); + if (index == p_resample->asrc_rate_idx) return 0; p_resample->asrc_rate_idx = index; - pr_info("%s resample_%c %s\n", - __func__, - (id == 0) ? 'a' : 'b', - auge_resample_texts[index]); - if (audio_resample_set(p_resample, (bool)index, resample_rate)) return 0; diff --git a/sound/soc/amlogic/auge/spdif.c b/sound/soc/amlogic/auge/spdif.c index 885be095..11066d7 100644 --- a/sound/soc/amlogic/auge/spdif.c +++ b/sound/soc/amlogic/auge/spdif.c @@ -1476,6 +1476,12 @@ static int aml_spdif_parse_of(struct platform_device *pdev) if (ret < 0) p_spdif->auto_asrc = 0; + if (p_spdif->auto_asrc < 0 || + p_spdif->auto_asrc > 7) { + pr_info("%s(), inval asrc setting %d\n", + __func__, p_spdif->auto_asrc); + p_spdif->auto_asrc = 0; + } pr_debug("SPDIF id %d asrc_id:%d auto_asrc:%d\n", p_spdif->id, p_spdif->asrc_id,