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