Skip to contentSkip to conversation

media: s5p-jpeg: Fix off-by-one problem

PATCH In review Flavio Ceolin 2 participants 2 messages Dec 6, 2017 – Dec 7, 2017 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: s5p-jpeg: Fix off-by-one problem

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).

---
 drivers/media/platform/s5p-jpeg/jpeg-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/s5p-jpeg/jpeg-core.c +1 -1
index faac816..79b63da 100644
@@ -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;
 		}
Signature · 1 line
2.9.5
Acked-by on v1 1/1
#1 lore raw

W dniu 06.12.2017 o?17:37, Flavio Ceolin pisze:

Quoted 6 lines

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).

Quoted 18 lines
---
  drivers/media/platform/s5p-jpeg/jpeg-core.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/s5p-jpeg/jpeg-core.c +1 -1
index faac816..79b63da 100644
@@ -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;
  		}