[PATCH 6/9] external/drm: Avoid negative array index value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



recode can be negative or zero as well. Put the correct condition
on it before using it as array index.

Signed-off-by: Praveen Paneri <praveen.paneri@xxxxxxxxx>
---
 xf86drm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xf86drm.c b/xf86drm.c
index 60663d4..df56f9e 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -585,7 +585,7 @@ static int drmOpenByName(const char *name)
 	if ((fd = open(proc_name, 0, 0)) >= 0) {
 	    retcode = read(fd, buf, sizeof(buf)-1);
 	    close(fd);
-	    if (retcode) {
+	    if (retcode > 0) {
 		buf[retcode-1] = '\0';
 		for (driver = pt = buf; *pt && *pt != ' '; ++pt)
 		    ;
-- 
1.9.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx





[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux