]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ASoC: qcom: q6dsp: Fix an off-by-one in q6adm_alloc_copp()
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Thu, 21 Jul 2022 09:02:22 +0000 (11:02 +0200)
committerMark Brown <broonie@kernel.org>
Thu, 21 Jul 2022 12:38:55 +0000 (13:38 +0100)
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 <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/0fca3271649736053eb9649d87e1ca01b056be40.1658394124.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/qcom/qdsp6/q6adm.c

index 01f383888b622321acaa73f4cdc5c368af2c87fb..1530e98df16564d683d7f81001e6e699fb53ee15 100644 (file)
@@ -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);