Blob Blame History Raw
From 53a21faf97723b0e4d6c2ec9a32f61fecfa2f246 Mon Sep 17 00:00:00 2001
From: Tomas Bzatek <tbzatek@redhat.com>
Date: Fri, 3 Aug 2018 11:26:16 +0200
Subject: [PATCH] lsm: Prevent overwriting already set error

---
 modules/lsm/lsm_local.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/modules/lsm/lsm_local.c b/modules/lsm/lsm_local.c
index 33ff198fd..a2a46442c 100644
--- a/modules/lsm/lsm_local.c
+++ b/modules/lsm/lsm_local.c
@@ -132,6 +132,12 @@ get_blk_path (UDisksDriveLsmLocal *ud_drv_lsm_local,
 
   ud_blk = udisks_object_get_block (UDISKS_OBJECT (ud_lx_blk_obj));
   blk_path = udisks_block_dup_device (ud_blk);
+  if (blk_path == NULL)
+    {
+      g_dbus_method_invocation_return_error (invocation, UDISKS_ERROR, UDISKS_ERROR_FAILED,
+                                             "Failed to retrieve block path of specified disk drive");
+      goto out;
+    }
 
 out:
   g_clear_object (&ud_blk);
@@ -156,9 +162,6 @@ led_control (UDisksDriveLsmLocal *ud_drv_lsm_local,
   blk_path = get_blk_path(ud_drv_lsm_local, invocation);
   if (blk_path == NULL)
     {
-      g_dbus_method_invocation_return_error
-        (invocation, UDISKS_ERROR, UDISKS_ERROR_FAILED,
-         "Failed to retrieve block path of specified disk drive");
       goto out;
     }