diff options
author | Chris Bainbridge <chris.bainbridge@gmail.com> | 2023-07-04 22:34:27 +0100 |
---|---|---|
committer | Chris Bainbridge <chris.bainbridge@gmail.com> | 2023-07-11 12:00:11 +0100 |
commit | 2897e1769c5d14a74bccbacb483667933807ead8 (patch) | |
tree | bc5d9bcc55a81514188704ae03ed2ce64f403409 /src | |
parent | 7025aefcdf9673665588cf291c5d71beb39cce89 (diff) |
Fix segfault on dock suspend, unplug, resume
`drmmode_set_mode` can segfault if a USB-C dock with external monitors
is disconnected during suspend. It appears that some data structures are
not updated, but the associated `drmModeConnectorPtr` associated with
those structures is NULL. Dereferencing that pointer results in Xorg
crashing.
Backtrace:
(crtc=crtc@entry=0x55a0c7610390, fb=fb@entry=0x55a0c86d7410, mode=mode@entry=0x55a0c76103a8, x=x@entry=0, y=y@entry=0) at drmmode_display.c:1267
(crtc=0x55a0c7610390, mode=0x55a0c76103a8, rotation=<optimized out>, x=<optimized out>, y=<optimized out>) at drmmode_display.c:1371
(main=main@entry=0x55a0c63f4b40, argc=argc@entry=10, argv=argv@entry=0x7fffb7cefbf8)
at ../sysdeps/nptl/libc_start_call_main.h:58
(main=0x55a0c63f4b40, argc=10, argv=0x7fffb7cefbf8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffb7cefbe8) at ../csu/libc-start.c:381
Fix this by checking the pointer before dereferencing it.
Fixes: https://gitlab.freedesktop.org/drm/amd/-/issues/2375
Signed-off-by: Chris Bainbridge <chris.bainbridge@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/drmmode_display.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/drmmode_display.c b/src/drmmode_display.c index 5b73fce..32e7f21 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -1264,6 +1264,9 @@ drmmode_set_mode(xf86CrtcPtr crtc, struct drmmode_fb *fb, DisplayModePtr mode, if (output->crtc != crtc) continue; + if (!drmmode_output->mode_output) + return FALSE; + output_ids[output_count] = drmmode_output->mode_output->connector_id; output_count++; } |