[PATCH xserver] modesetting: Do not close uninitialized dri2 screen
Jeff Smith
whydoubt at gmail.com
Thu Feb 15 12:46:55 UTC 2018
If a dri2 screen is not successfully initialized, attempting to close it
results in a null dereference.
Maintain a flag indicating whether the dri2 screen was successfully
initialized, and check it before attempting to close the dri2 screen.
https://bugzilla.redhat.com/show_bug.cgi?id=1485811
https://bugzilla.redhat.com/show_bug.cgi?id=1493805
https://bugzilla.redhat.com/show_bug.cgi?id=1534459
https://bugzilla.redhat.com/show_bug.cgi?id=1541745
https://bugs.freedesktop.org/show_bug.cgi?id=101282
Signed-off-by: Jeff Smith <whydoubt at gmail.com>
---
hw/xfree86/drivers/modesetting/driver.c | 6 +++---
hw/xfree86/drivers/modesetting/drmmode_display.h | 3 +++
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c
index 380dbbe17..13f4e5ab6 100644
--- a/hw/xfree86/drivers/modesetting/driver.c
+++ b/hw/xfree86/drivers/modesetting/driver.c
@@ -1685,12 +1685,12 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv)
#ifdef GLAMOR_HAS_GBM
if (ms->drmmode.glamor) {
- if (!ms_dri2_screen_init(pScreen)) {
+ if (!(ms->drmmode.dri2_enable = ms_dri2_screen_init(pScreen))) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"Failed to initialize the DRI2 extension.\n");
}
- if (!ms_present_screen_init(pScreen)) {
+ if (!(ms->drmmode.present_enable = ms_present_screen_init(pScreen))) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"Failed to initialize the Present extension.\n");
}
@@ -1783,7 +1783,7 @@ CloseScreen(ScreenPtr pScreen)
ms_ent->assigned_crtcs = 0;
#ifdef GLAMOR_HAS_GBM
- if (ms->drmmode.glamor) {
+ if (ms->drmmode.dri2_enable) {
ms_dri2_close_screen(pScreen);
}
#endif
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.h b/hw/xfree86/drivers/modesetting/drmmode_display.h
index a12f2c3f1..09c5e6ff7 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.h
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.h
@@ -83,6 +83,9 @@ typedef struct {
Bool dri2_flipping;
Bool present_flipping;
+
+ Bool dri2_enable;
+ Bool present_enable;
} drmmode_rec, *drmmode_ptr;
typedef struct {
--
2.14.3
More information about the xorg-devel
mailing list