From a3ddf73c0e4abf8e3c1b8fd91eac469220a5b44b Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 2 Mar 2018 11:55:16 +0100 Subject: [PATCH 1/4] logind: voidify a function we never check the return value of --- src/login/logind-session-device.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/login/logind-session-device.c b/src/login/logind-session-device.c index 65b4bb849bf..706245de423 100644 --- a/src/login/logind-session-device.c +++ b/src/login/logind-session-device.c @@ -106,7 +106,7 @@ static int session_device_notify(SessionDevice *sd, enum SessionDeviceNotificati return sd_bus_send(sd->session->manager->bus, m, NULL); } -static int sd_eviocrevoke(int fd) { +static void sd_eviocrevoke(int fd) { static bool warned = false; assert(fd >= 0); @@ -118,8 +118,6 @@ static int sd_eviocrevoke(int fd) { warned = true; } } - - return 0; } static int sd_drmsetmaster(int fd) { From 4804600b6a38994ce4157163fe8af68a0c83e3f0 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 2 Mar 2018 11:55:33 +0100 Subject: [PATCH 2/4] logind: cast away return value we don't care about --- src/login/logind-session-device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/login/logind-session-device.c b/src/login/logind-session-device.c index 706245de423..db148d19163 100644 --- a/src/login/logind-session-device.c +++ b/src/login/logind-session-device.c @@ -164,7 +164,7 @@ static int session_device_open(SessionDevice *sd, bool active) { } else /* DRM-Master is granted to the first user who opens a device automatically (ughh, * racy!). Hence, we just drop DRM-Master in case we were the first. */ - sd_drmdropmaster(fd); + (void) sd_drmdropmaster(fd); break; case DEVICE_TYPE_EVDEV: From 4d3900f1b7ccce03366f9a57d259d0735c1cfbcf Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 2 Mar 2018 11:55:51 +0100 Subject: [PATCH 3/4] logind: open device if needed Fixes: #8291 --- src/login/logind-session-device.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) 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: From 340aff15f89351b118a717967418c218b3dd0279 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 2 Mar 2018 11:56:15 +0100 Subject: [PATCH 4/4] logind: fix typo in comment --- src/login/logind-session-device.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/login/logind-session-device.c b/src/login/logind-session-device.c index b7476e7d087..c64fb4359b9 100644 --- a/src/login/logind-session-device.c +++ b/src/login/logind-session-device.c @@ -222,7 +222,7 @@ static int session_device_start(SessionDevice *sd) { case DEVICE_TYPE_UNKNOWN: default: - /* fallback for devices wihout synchronizations */ + /* fallback for devices without synchronizations */ break; } @@ -237,6 +237,7 @@ static void session_device_stop(SessionDevice *sd) { return; switch (sd->type) { + case DEVICE_TYPE_DRM: /* On DRM devices we simply drop DRM-Master but keep it open. * This allows the user to keep resources allocated. The @@ -244,6 +245,7 @@ static void session_device_stop(SessionDevice *sd) { * circumventing this. */ sd_drmdropmaster(sd->fd); break; + case DEVICE_TYPE_EVDEV: /* Revoke access on evdev file-descriptors during deactivation. * This will basically prevent any operations on the fd and @@ -251,6 +253,7 @@ static void session_device_stop(SessionDevice *sd) { * protection this way. */ sd_eviocrevoke(sd->fd); break; + case DEVICE_TYPE_UNKNOWN: default: /* fallback for devices without synchronization */ @@ -468,6 +471,7 @@ void session_device_resume_all(Session *s) { continue; if (session_device_save(sd) < 0) continue; + session_device_notify(sd, SESSION_DEVICE_RESUME); } }