mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-11 13:27:06 +09:00
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 <shuai.li@amlogic.com>
This commit is contained in:
@@ -274,6 +274,11 @@ int resample_set(enum resample_idx id, enum samplerate_index index)
|
||||
if (!p_resample)
|
||||
return 0;
|
||||
|
||||
if (index < RATE_OFF || index > RATE_192K) {
|
||||
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',
|
||||
@@ -284,7 +289,7 @@ int resample_set(enum resample_idx id, enum samplerate_index index)
|
||||
if (index == p_resample->asrc_rate_idx)
|
||||
return 0;
|
||||
#endif
|
||||
p_resample->asrc_rate_idx = index;
|
||||
set_resample_rate_index(id, index);
|
||||
|
||||
resample_rate = resample_idx2rate(index);
|
||||
ret = audio_resample_set(p_resample, (bool)index, resample_rate);
|
||||
|
||||
@@ -1492,6 +1492,12 @@ static int aml_spdif_parse_of(struct platform_device *pdev)
|
||||
if (ret < 0)
|
||||
p_spdif->auto_asrc = 0;
|
||||
|
||||
if (p_spdif->auto_asrc < RATE_OFF ||
|
||||
p_spdif->auto_asrc > RATE_192K) {
|
||||
pr_info("%s(), inval asrc setting %d\n",
|
||||
__func__, p_spdif->auto_asrc);
|
||||
p_spdif->auto_asrc = RATE_OFF;
|
||||
}
|
||||
pr_debug("SPDIF id %d asrc_id:%d auto_asrc:%d\n",
|
||||
p_spdif->id,
|
||||
p_spdif->asrc_id,
|
||||
|
||||
Reference in New Issue
Block a user