media: s5p-jpeg: Fix off-by-one problem
authorFlavio Ceolin <flavio.ceolin@intel.com>
Wed, 6 Dec 2017 16:37:45 +0000 (11:37 -0500)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Mon, 18 Dec 2017 20:12:30 +0000 (15:12 -0500)
s5p_jpeg_runtime_resume() does not call clk_disable_unprepare()
for jpeg->clocks[0] when one of the clk_prepare_enable() fails.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Acked-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/platform/s5p-jpeg/jpeg-core.c

index faac816..79b63da 100644 (file)
@@ -3086,7 +3086,7 @@ static int s5p_jpeg_runtime_resume(struct device *dev)
        for (i = 0; i < jpeg->variant->num_clocks; i++) {
                ret = clk_prepare_enable(jpeg->clocks[i]);
                if (ret) {
-                       while (--i > 0)
+                       while (--i >= 0)
                                clk_disable_unprepare(jpeg->clocks[i]);
                        return ret;
                }