From 6804875662363764683a86c1614e4cf3cc70a20a Mon Sep 17 00:00:00 2001 From: Daniel Martin Date: Mon, 20 Nov 2017 10:47:41 +0100 Subject: [PATCH] modesetting: Reset output_id if drmModeGetConnector failed 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. Reviewed-by: Adam Jackson Signed-off-by: Daniel Martin --- hw/xfree86/drivers/modesetting/drmmode_display.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c index 404bb1dc2..3b8107359 100644 --- a/hw/xfree86/drivers/modesetting/drmmode_display.c +++ b/hw/xfree86/drivers/modesetting/drmmode_display.c @@ -1151,8 +1151,10 @@ drmmode_output_detect(xf86OutputPtr output) drmmode_output->mode_output = drmModeGetConnector(drmmode->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: