[gvfs/gnome-3-24] mtp: Handle uevents only in case of mount success



commit 10aa565fc5bc81235d81b246528853ff26004b05
Author: Ondrej Holy <oholy redhat com>
Date:   Fri Feb 16 10:13:22 2018 +0100

    mtp: Handle uevents only in case of mount success
    
    Uevents handler can be connected even if mount operation failed (e.g.
    device is unplugged in the middle of mount operation). Backend is
    consequently finalized, however, g_vfs_backend_force_unmount can be
    still called from on_uevent in the meantime. This might cause segfaults
    in certain cases.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=787992

 daemon/gvfsbackendmtp.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/daemon/gvfsbackendmtp.c b/daemon/gvfsbackendmtp.c
index 798b7f9..b0da754 100644
--- a/daemon/gvfsbackendmtp.c
+++ b/daemon/gvfsbackendmtp.c
@@ -914,14 +914,14 @@ do_mount (GVfsBackend *backend,
   op_backend->volume_symbolic_icon = g_vfs_get_volume_symbolic_icon (device);
   g_object_unref (device);
 
-  g_signal_connect (op_backend->gudev_client, "uevent", G_CALLBACK (on_uevent), op_backend);
-
-  op_backend->file_cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
-
   LIBMTP_Init ();
 
   get_device (backend, host, G_VFS_JOB (job));
   if (!G_VFS_JOB (job)->failed) {
+    g_signal_connect (op_backend->gudev_client, "uevent", G_CALLBACK (on_uevent), op_backend);
+
+    op_backend->file_cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+
     GMountSpec *mtp_mount_spec = g_mount_spec_new ("mtp");
     g_mount_spec_set (mtp_mount_spec, "host", host);
     g_vfs_backend_set_mount_spec (backend, mtp_mount_spec);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]