lkml.org 
[lkml]   [2017]   [Dec]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] gpu: ipu-v3: prg: avoid possible array underflow
Date
gcc-8 reports that we access an array with a negative index
in an error case:

drivers/gpu/ipu-v3/ipu-prg.c: In function 'ipu_prg_channel_disable':
drivers/gpu/ipu-v3/ipu-prg.c:252:43: error: array subscript -22 is below array bounds of 'struct ipu_prg_channel[3]' [-Werror=array-bounds]

This moves the range check in front of the dereference.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/gpu/ipu-v3/ipu-prg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/ipu-v3/ipu-prg.c b/drivers/gpu/ipu-v3/ipu-prg.c
index 0013ca9f72c8..1417db856989 100644
--- a/drivers/gpu/ipu-v3/ipu-prg.c
+++ b/drivers/gpu/ipu-v3/ipu-prg.c
@@ -252,7 +252,7 @@ void ipu_prg_channel_disable(struct ipuv3_channel *ipu_chan)
struct ipu_prg_channel *chan = &prg->chan[prg_chan];
u32 val;

- if (!chan->enabled || prg_chan < 0)
+ if (prg_chan < 0 || !chan->enabled)
return;

clk_prepare_enable(prg->clk_ipg);
--
2.9.0
\
 
 \ /
  Last update: 2017-12-04 15:54    [W:0.020 / U:3.512 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site