lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <4991E812.80606@gmail.com>
Date:	Tue, 10 Feb 2009 21:48:18 +0100
From:	Roel Kluin <roel.kluin@...il.com>
To:	Thomas Hellström <thomas@...pmail.org>
CC:	airlied@...ux.ie, dri-devel@...ts.sourceforge.net,
	lkml <linux-kernel@...r.kernel.org>
Subject: [PATCH v2] drm: count reaches -1, tested 0

Thomas Hellström wrote:

> This code is about to be abandoned, but if we're going to fix it,
> instead of pushing the problem to then next while loop, what about
> 
> while (count && condition)
>    count--;
> 
> Can you redo the patch based on that?

Very well reviewed, thanks. Like this?
------------------->8-----------------------8<------------------------

With a postfix decrement in the test count will reach -1 rather than 0,
subsequent tests fail.

Signed-off-by: Roel Kluin <roel.kluin@...il.com>
---
diff --git a/drivers/gpu/drm/via/via_dma.c b/drivers/gpu/drm/via/via_dma.c
index 7a339db..029c22a 100644
--- a/drivers/gpu/drm/via/via_dma.c
+++ b/drivers/gpu/drm/via/via_dma.c
@@ -481,11 +481,12 @@ static int via_wait_idle(drm_via_private_t * dev_priv)
 {
 	int count = 10000000;
 
-	while (!(VIA_READ(VIA_REG_STATUS) & VIA_VR_QUEUE_BUSY) && count--);
+	while (!(VIA_READ(VIA_REG_STATUS) & VIA_VR_QUEUE_BUSY) && --count)
+		;
 
-	while (count-- && (VIA_READ(VIA_REG_STATUS) &
-			   (VIA_CMD_RGTR_BUSY | VIA_2D_ENG_BUSY |
-			    VIA_3D_ENG_BUSY))) ;
+	while (count && (VIA_READ(VIA_REG_STATUS) & (VIA_CMD_RGTR_BUSY |
+					VIA_2D_ENG_BUSY | VIA_3D_ENG_BUSY)))
+		count--;
 	return count;
 }
 
@@ -705,7 +706,7 @@ static int via_cmdbuf_size(struct drm_device *dev, void *data, struct drm_file *
 	switch (d_siz->func) {
 	case VIA_CMDBUF_SPACE:
 		while (((tmp_size = via_cmdbuf_space(dev_priv)) < d_siz->size)
-		       && count--) {
+		       && --count) {
 			if (!d_siz->wait) {
 				break;
 			}
@@ -717,7 +718,7 @@ static int via_cmdbuf_size(struct drm_device *dev, void *data, struct drm_file *
 		break;
 	case VIA_CMDBUF_LAG:
 		while (((tmp_size = via_cmdbuf_lag(dev_priv)) > d_siz->size)
-		       && count--) {
+		       && --count) {
 			if (!d_siz->wait) {
 				break;
 			}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ