chiark / gitweb /
logind: open device if needed
authorLennart Poettering <lennart@poettering.net>
Fri, 2 Mar 2018 10:55:51 +0000 (11:55 +0100)
committerSven Eden <yamakuzure@gmx.net>
Wed, 30 May 2018 05:59:11 +0000 (07:59 +0200)
Fixes: #8291
src/login/logind-session-device.c

index 64a6bd273f392d2d153fda84d6dd97c7560e3d47..ca0c512a1aae79837f4aa90a13987ffb5fe7c5e6 100644 (file)
@@ -197,11 +197,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: