Skip to contentSkip to conversation

gpu: ipu-v3: prg: avoid possible array underflow

PATCH RESEND Applied Arnd Bergmann 2 participants 2 messages Jan 16, 2018

Subsystems (2)

v1 of 3 Applied Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 gpu: ipu-v3: prg: avoid possible array underflow

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.

----
Originally sent on Dec 4, 2017. No reply, so resending unchanged.

---
 drivers/gpu/ipu-v3/ipu-prg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/ipu-v3/ipu-prg.c +1 -1
index 067365c733c6..0bcb935e525c 100644
@@ -250,7 +250,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;
 
 	pm_runtime_get_sync(prg->dev);
Signature · 6 lines
2.9.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
maintainer Applied
#1 lore raw

Hi Arnd,

Quoted 11 lines · Arnd Bergmann

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.

----
Originally sent on Dec 4, 2017. No reply, so resending unchanged.

Thank you, applied to imx-drm/fixes.

regards
Philipp