]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
media: venus: fix loop wrap in cleanup of clks
authorColin Ian King <colin.king@canonical.com>
Thu, 22 Jun 2017 17:27:21 +0000 (14:27 -0300)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Sat, 24 Jun 2017 12:38:53 +0000 (09:38 -0300)
The current pre-decrement is incorrect and should be replaced
with a post-decrement. Consider the case where the very first
clk_prepare_enable fails when i is 0; in this case the error
clean up will decrement the unsigned int which wraps to the
largest unsigned int value causing an array out of bounds read
on core->clks[i].

Detected by CoverityScan, CID#1446590 ("Out-of-bounds read")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/platform/qcom/venus/core.c

index 776d2bae697934f02d3ce70fa1adfe4c1d35966a..d8cbe8549d975d229606bef98ee8cc77bcdc9145 100644 (file)
@@ -137,7 +137,7 @@ static int venus_clks_enable(struct venus_core *core)
 
        return 0;
 err:
-       while (--i)
+       while (i--)
                clk_disable_unprepare(core->clks[i]);
 
        return ret;