dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Liu Ying <gnuiyl@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: Thierry Reding <treding@nvidia.com>
Subject: [PATCH libdrm] tests: kms: screen probe: Get screen mode when con->count_modes is nonzero
Date: Fri, 17 Nov 2017 12:47:28 +0800	[thread overview]
Message-ID: <1510894048-3715-1-git-send-email-gnuiyl@gmail.com> (raw)

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@gmail.com>
---
 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@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

                 reply	other threads:[~2017-11-17  6:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1510894048-3715-1-git-send-email-gnuiyl@gmail.com \
    --to=gnuiyl@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=treding@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox