dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [RESEND] gpu: ipu-v3: prg: avoid possible array underflow
@ 2018-01-16 14:31 Arnd Bergmann
  2018-01-16 15:02 ` Philipp Zabel
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2018-01-16 14:31 UTC (permalink / raw)
  To: Philipp Zabel; +Cc: linux-kernel, dri-devel, 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.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
----
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(-)

diff --git a/drivers/gpu/ipu-v3/ipu-prg.c b/drivers/gpu/ipu-v3/ipu-prg.c
index 067365c733c6..0bcb935e525c 100644
--- a/drivers/gpu/ipu-v3/ipu-prg.c
+++ b/drivers/gpu/ipu-v3/ipu-prg.c
@@ -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);
-- 
2.9.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] [RESEND] gpu: ipu-v3: prg: avoid possible array underflow
  2018-01-16 14:31 [PATCH] [RESEND] gpu: ipu-v3: prg: avoid possible array underflow Arnd Bergmann
@ 2018-01-16 15:02 ` Philipp Zabel
  0 siblings, 0 replies; 2+ messages in thread
From: Philipp Zabel @ 2018-01-16 15:02 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Lucas Stach, dri-devel, linux-kernel

Hi Arnd,

On Tue, 2018-01-16 at 15:31 +0100, Arnd Bergmann wrote:
> 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>
> ----
> Originally sent on Dec 4, 2017. No reply, so resending unchanged.

Thank you, applied to imx-drm/fixes.

regards
Philipp

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-01-16 15:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-16 14:31 [PATCH] [RESEND] gpu: ipu-v3: prg: avoid possible array underflow Arnd Bergmann
2018-01-16 15:02 ` Philipp Zabel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).