From: Lennart Poettering Date: Fri, 2 Mar 2018 10:55:51 +0000 (+0100) Subject: logind: open device if needed X-Git-Tag: v238~20^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4d3900f1b7ccce03366f9a57d259d0735c1cfbcf;p=thirdparty%2Fsystemd.git logind: open device if needed Fixes: #8291 --- diff --git a/src/login/logind-session-device.c b/src/login/logind-session-device.c index db148d19163..b7476e7d087 100644 --- a/src/login/logind-session-device.c +++ b/src/login/logind-session-device.c @@ -193,11 +193,19 @@ static int session_device_start(SessionDevice *sd) { switch (sd->type) { case DEVICE_TYPE_DRM: - /* Device is kept open. Simply call drmSetMaster() and hope there is no-one else. In case it fails, we - * keep the device paused. Maybe at some point we have a drmStealMaster(). */ - r = sd_drmsetmaster(sd->fd); - if (r < 0) - return r; + + if (sd->fd < 0) { + /* Open device if it isn't open yet */ + sd->fd = session_device_open(sd, true); + if (sd->fd < 0) + return sd->fd; + } else { + /* Device is kept open. Simply call drmSetMaster() and hope there is no-one else. In case it fails, we + * keep the device paused. Maybe at some point we have a drmStealMaster(). */ + r = sd_drmsetmaster(sd->fd); + if (r < 0) + return r; + } break; case DEVICE_TYPE_EVDEV: