[PATCH libdrm] tests: kms: screen probe: Get screen mode when con->count_modes is nonzero

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

 



We should not get screen mode when a connector has no modes,
but just leave it be zero.
This may avoid the segmentation fault issue when a connector
status is disconnected, which is caused by memory copying
from a NULL connector mode pointer to a screen mode.

Signed-off-by: Liu Ying <gnuiyl@xxxxxxxxx>
---
 tests/kms/libkms-test-screen.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/kms/libkms-test-screen.c b/tests/kms/libkms-test-screen.c
index 3369022..9ecf032 100644
--- a/tests/kms/libkms-test-screen.c
+++ b/tests/kms/libkms-test-screen.c
@@ -46,7 +46,8 @@ static void kms_screen_probe(struct kms_screen *screen)
 	else
 		screen->connected = false;
 
-	memcpy(&screen->mode, &con->modes[0], sizeof(drmModeModeInfo));
+	if (con->count_modes)
+		memcpy(&screen->mode, &con->modes[0], sizeof(drmModeModeInfo));
 	screen->width = screen->mode.hdisplay;
 	screen->height = screen->mode.vdisplay;
 
-- 
2.7.4

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




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux