Skip to contentSkip to conversation

tests: kms: screen probe: Get screen mode when con->count_modes is nonzero

PATCH New Liu Ying 1 participant 1 message Nov 17, 2017

lore
Share & tools
lore

Liu Ying

author
#0 lore raw

PATCH 1/1 tests: kms: screen probe: Get screen mode when con->count_modes is nonzero

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.

---
 tests/kms/libkms-test-screen.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tests/kms/libkms-test-screen.c +2 -1
index 3369022..9ecf032 100644
@@ -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;
 
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel