598898
From f486a9fa22c2f9785a4a8fc58eb3be7b0cf934ce Mon Sep 17 00:00:00 2001
598898
From: Tomas Bzatek <tbzatek@redhat.com>
598898
Date: Sat, 1 Jan 2022 19:59:27 +0100
598898
Subject: [PATCH] udiskslinuxpartitiontable: Fix GError ownership
598898
598898
---
598898
 src/udiskslinuxpartitiontable.c | 11 ++++-------
598898
 1 file changed, 4 insertions(+), 7 deletions(-)
598898
598898
diff --git a/src/udiskslinuxpartitiontable.c b/src/udiskslinuxpartitiontable.c
598898
index b4c301095..14a54c9c7 100644
598898
--- a/src/udiskslinuxpartitiontable.c
598898
+++ b/src/udiskslinuxpartitiontable.c
598898
@@ -277,7 +277,7 @@ udisks_linux_partition_table_handle_create_partition (UDisksPartitionTable   *ta
598898
   object = udisks_daemon_util_dup_object (table, &error);
598898
   if (object == NULL)
598898
     {
598898
-      g_dbus_method_invocation_take_error (invocation, error);
598898
+      g_dbus_method_invocation_return_gerror (invocation, error);
598898
       goto out;
598898
     }
598898
 
598898
@@ -293,7 +293,6 @@ udisks_linux_partition_table_handle_create_partition (UDisksPartitionTable   *ta
598898
       goto out;
598898
     }
598898
 
598898
-  error = NULL;
598898
   if (!udisks_daemon_util_get_caller_uid_sync (daemon,
598898
                                                invocation,
598898
                                                NULL /* GCancellable */,
598898
@@ -301,7 +300,6 @@ udisks_linux_partition_table_handle_create_partition (UDisksPartitionTable   *ta
598898
                                                &error))
598898
     {
598898
       g_dbus_method_invocation_return_gerror (invocation, error);
598898
-      g_clear_error (&error);
598898
       goto out;
598898
     }
598898
 
598898
@@ -464,7 +462,7 @@ udisks_linux_partition_table_handle_create_partition (UDisksPartitionTable   *ta
598898
       if (!bd_part_set_part_name (device_name, part_spec->path, name, &error))
598898
         {
598898
           g_prefix_error (&error, "Error setting name for newly created partition: ");
598898
-          g_dbus_method_invocation_take_error (invocation, error);
598898
+          g_dbus_method_invocation_return_gerror (invocation, error);
598898
           udisks_simple_job_complete (UDISKS_SIMPLE_JOB (job), FALSE, error->message);
598898
           goto out;
598898
         }
598898
@@ -483,7 +481,7 @@ udisks_linux_partition_table_handle_create_partition (UDisksPartitionTable   *ta
598898
       if (!ret)
598898
         {
598898
           g_prefix_error (&error, "Error setting type for newly created partition: ");
598898
-          g_dbus_method_invocation_take_error (invocation, error);
598898
+          g_dbus_method_invocation_return_gerror (invocation, error);
598898
           udisks_simple_job_complete (UDISKS_SIMPLE_JOB (job), FALSE, error->message);
598898
           goto out;
598898
         }
598898
@@ -520,7 +518,6 @@ udisks_linux_partition_table_handle_create_partition (UDisksPartitionTable   *ta
598898
   /* sit and wait for the partition to show up */
598898
   g_warn_if_fail (wait_data->pos_to_wait_for > 0);
598898
   wait_data->partition_table_object = object;
598898
-  error = NULL;
598898
   partition_object = udisks_daemon_wait_for_object_sync (daemon,
598898
                                                          wait_for_partition,
598898
                                                          wait_data,
598898
@@ -530,7 +527,7 @@ udisks_linux_partition_table_handle_create_partition (UDisksPartitionTable   *ta
598898
   if (partition_object == NULL)
598898
     {
598898
       g_prefix_error (&error, "Error waiting for partition to appear: ");
598898
-      g_dbus_method_invocation_take_error (invocation, error);
598898
+      g_dbus_method_invocation_return_gerror (invocation, error);
598898
       udisks_simple_job_complete (UDISKS_SIMPLE_JOB (job), FALSE, error->message);
598898
       goto out;
598898
     }