diff --git a/src/backends/native/meta-device-pool.c b/src/backends/native/meta-device-pool.c index baca12c5f..69e3e8d2f 100644 --- a/src/backends/native/meta-device-pool.c +++ b/src/backends/native/meta-device-pool.c @@ -211,7 +211,7 @@ meta_device_pool_open (MetaDevicePool *pool, { g_autoptr (GMutexLocker) locker = NULL; MetaDeviceFile *file; - int major, minor; + int major = -1, minor = -1; int fd; locker = g_mutex_locker_new (&pool->mutex); @@ -224,15 +224,6 @@ meta_device_pool_open (MetaDevicePool *pool, return file; } - if (!get_device_info_from_path (path, &major, &minor)) - { - g_set_error (error, - G_IO_ERROR, - G_IO_ERROR_NOT_FOUND, - "Could not get device info for path %s: %m", path); - return NULL; - } - if (flags & META_DEVICE_FILE_FLAG_TAKE_CONTROL) { if (!pool->session_proxy) @@ -242,6 +233,15 @@ meta_device_pool_open (MetaDevicePool *pool, return NULL; } + if (!get_device_info_from_path (path, &major, &minor)) + { + g_set_error (error, + G_IO_ERROR, + G_IO_ERROR_NOT_FOUND, + "Could not get device info for path %s: %m", path); + return NULL; + } + if (!take_device (pool->session_proxy, major, minor, &fd, NULL, error)) return NULL; }