From: Christophe JAILLET Date: Thu, 21 Jul 2022 09:02:22 +0000 (+0200) Subject: ASoC: qcom: q6dsp: Fix an off-by-one in q6adm_alloc_copp() X-Git-Tag: baikal/mips/sdk5.9~154 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=8c23aaa3aad3a0b3b3e98c03a1fd8b4aaffa0364;p=kernel.git ASoC: qcom: q6dsp: Fix an off-by-one in q6adm_alloc_copp() [ Upstream commit 99e398a8ff7104482fed345b1208ad3f2aece8bd ] find_first_zero_bit() returns MAX_COPPS_PER_PORT at max here. So 'idx' should be tested with ">=" or the test can't match. Fixes: 5285a55a4a8f ("ASoC: qdsp6: q6adm: Add q6adm driver") Signed-off-by: Christophe JAILLET Link: https://lore.kernel.org/r/0fca3271649736053eb9649d87e1ca01b056be40.1658394124.git.christophe.jaillet@wanadoo.fr Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- diff --git a/sound/soc/qcom/qdsp6/q6adm.c b/sound/soc/qcom/qdsp6/q6adm.c index 3d831b635524f..4ae97afe90624 100644 --- a/sound/soc/qcom/qdsp6/q6adm.c +++ b/sound/soc/qcom/qdsp6/q6adm.c @@ -217,7 +217,7 @@ static struct q6copp *q6adm_alloc_copp(struct q6adm *adm, int port_idx) idx = find_first_zero_bit(&adm->copp_bitmap[port_idx], MAX_COPPS_PER_PORT); - if (idx > MAX_COPPS_PER_PORT) + if (idx >= MAX_COPPS_PER_PORT) return ERR_PTR(-EBUSY); c = kzalloc(sizeof(*c), GFP_ATOMIC);