All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michel Dänzer" <michel-otUistvHUpPR7s880joybQ@public.gmane.org>
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: [PATCH xf86-video-amdgpu 2/3] modesetting: Reset output_id if drmModeGetConnector failed
Date: Thu, 22 Feb 2018 18:52:52 +0100	[thread overview]
Message-ID: <20180222175253.13842-2-michel@daenzer.net> (raw)
In-Reply-To: <20180222175253.13842-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>

From: Daniel Martin <consume.noise@gmail.com>

If drmModeGetConnector() fails in drmmode_output_detect(), we have to
reset the output_id to -1 too.

Yet another spot leading to a potential NULL dereference when handling
the mode_output member as output_id was != -1. Though, this case should
be very hard to hit.

Signed-off-by: Daniel Martin <consume.noise@gmail.com>

(Ported from xserver commit 6804875662363764683a86c1614e4cf3cc70a20a)

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
---
 src/drmmode_display.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 98d2039d0..a90fdb642 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1378,8 +1378,10 @@ static xf86OutputStatus drmmode_output_detect(xf86OutputPtr output)
 
 	drmmode_output->mode_output =
 	    drmModeGetConnector(pAMDGPUEnt->fd, drmmode_output->output_id);
-	if (!drmmode_output->mode_output)
+	if (!drmmode_output->mode_output) {
+		drmmode_output->output_id = -1;
 		return XF86OutputStatusDisconnected;
+	}
 
 	switch (drmmode_output->mode_output->connection) {
 	case DRM_MODE_CONNECTED:
-- 
2.16.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2018-02-22 17:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-22 17:52 [PATCH xf86-video-amdgpu 1/3] modesetting: Use helper to fetch drmModeProperty(Blob)s Michel Dänzer
     [not found] ` <20180222175253.13842-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
2018-02-22 17:52   ` Michel Dänzer [this message]
2018-02-22 17:52   ` [PATCH xf86-video-amdgpu 3/3] modesetting: Update property values at detect and uevent time Michel Dänzer
     [not found]     ` <20180222175253.13842-3-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
2018-02-23  5:17       ` Alex Deucher

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=20180222175253.13842-2-michel@daenzer.net \
    --to=michel-otuistvhuppr7s880joybq@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.