[Xf86-video-armsoc] [PATCH 1/1] Fix unsafe pointer-to-int casting

armsoc-bugs at arm.com armsoc-bugs at arm.com
Fri Jan 31 09:34:34 PST 2014


From: Ray Smith <raymond.smith at arm.com>

Change-Id: I1d183f7ac1148828132be4a2a22bbfbc29fe937e
---
 src/armsoc_driver.c   |    4 ++--
 src/armsoc_driver.h   |    4 ++--
 src/drmmode_display.c |   15 ++++++++-------
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/armsoc_driver.c b/src/armsoc_driver.c
index 3fe6747..96989e4 100644
--- a/src/armsoc_driver.c
+++ b/src/armsoc_driver.c
@@ -310,7 +310,7 @@ ARMSOCOpenDRM(ScrnInfoPtr pScrn)
 		connection.fd = pARMSOC->drmFD;
 		connection.open_count = 1;
 		connection.master_count = 1;
-		drmmode_init_wakeup_handler(connection.fd);
+		drmmode_init_wakeup_handler(pARMSOC);
 	} else {
 		assert(connection.open_count);
 		connection.open_count++;
@@ -335,7 +335,7 @@ ARMSOCCloseDRM(ScrnInfoPtr pScrn)
 		connection.open_count--;
 		if (!connection.open_count) {
 			assert(!connection.master_count);
-			drmmode_fini_wakeup_handler(connection.fd);
+			drmmode_fini_wakeup_handler(pARMSOC);
 			drmClose(pARMSOC->drmFD);
 			connection.fd = -1;
 		}
diff --git a/src/armsoc_driver.h b/src/armsoc_driver.h
index c4c1fd5..060ac45 100644
--- a/src/armsoc_driver.h
+++ b/src/armsoc_driver.h
@@ -198,8 +198,8 @@ Bool drmmode_page_flip(DrawablePtr draw, uint32_t fb_id, void *priv);
 void drmmode_wait_for_event(ScrnInfoPtr pScrn);
 Bool drmmode_cursor_init(ScreenPtr pScreen);
 void drmmode_cursor_fini(ScreenPtr pScreen);
-void drmmode_init_wakeup_handler(int fd);
-void drmmode_fini_wakeup_handler(int fd);
+void drmmode_init_wakeup_handler(struct ARMSOCRec *pARMSOC);
+void drmmode_fini_wakeup_handler(struct ARMSOCRec *pARMSOC);
 
 
 /**
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 74fec09..a5f844d 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1807,7 +1807,8 @@ drmmode_uevent_fini(ScrnInfoPtr pScrn)
 static void
 drmmode_wakeup_handler(pointer data, int err, pointer p)
 {
-	int fd = (int)data;
+	struct ARMSOCRec *pARMSOC = (struct ARMSOCRec *)data;
+	int fd = pARMSOC->drmFD;
 	fd_set *read_mask = p;
 
 	if (err < 0)
@@ -1817,18 +1818,18 @@ drmmode_wakeup_handler(pointer data, int err, pointer p)
 		drmHandleEvent(fd, &event_context);
 }
 
-void drmmode_init_wakeup_handler(int fd)
+void drmmode_init_wakeup_handler(struct ARMSOCRec *pARMSOC)
 {
-	AddGeneralSocket(fd);
+	AddGeneralSocket(pARMSOC->drmFD);
 	RegisterBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA,
-			drmmode_wakeup_handler, (pointer)fd);
+			drmmode_wakeup_handler, pARMSOC);
 }
 
-void drmmode_fini_wakeup_handler(int fd)
+void drmmode_fini_wakeup_handler(struct ARMSOCRec *pARMSOC)
 {
 	RemoveBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA,
-			drmmode_wakeup_handler, (pointer)fd);
-	RemoveGeneralSocket(fd);
+			drmmode_wakeup_handler, pARMSOC);
+	RemoveGeneralSocket(pARMSOC->drmFD);
 }
 
 void
-- 
1.7.9.5



More information about the Xf86-video-armsoc mailing list