b3f87c
From 0789fc7f227b557d9633402bf9971ff7a6360447 Mon Sep 17 00:00:00 2001
b3f87c
From: Tomas Bzatek <tbzatek@redhat.com>
b3f87c
Date: Wed, 24 Apr 2019 16:03:31 +0200
b3f87c
Subject: [PATCH 01/17] lvm: Fix some obvious memory leaks
b3f87c
b3f87c
---
b3f87c
 src/plugins/lvm.c | 7 +++++++
b3f87c
 1 file changed, 7 insertions(+)
b3f87c
b3f87c
diff --git a/src/plugins/lvm.c b/src/plugins/lvm.c
b3f87c
index 87ff5a4..a23f8fd 100644
b3f87c
--- a/src/plugins/lvm.c
b3f87c
+++ b/src/plugins/lvm.c
b3f87c
@@ -371,6 +371,7 @@ static GHashTable* parse_lvm_vars (const gchar *str, guint *num_items) {
b3f87c
         if (g_strv_length (key_val) == 2) {
b3f87c
             /* we only want to process valid lines (with the '=' character) */
b3f87c
             g_hash_table_insert (table, key_val[0], key_val[1]);
b3f87c
+            g_free (key_val);
b3f87c
             (*num_items)++;
b3f87c
         } else
b3f87c
             /* invalid line, just free key_val */
b3f87c
@@ -972,6 +973,7 @@ BDLVMPVdata* bd_lvm_pvinfo (const gchar *device, GError **error) {
b3f87c
             if (table)
b3f87c
                 g_hash_table_destroy (table);
b3f87c
     }
b3f87c
+    g_strfreev (lines);
b3f87c
 
b3f87c
     /* getting here means no usable info was found */
b3f87c
     g_set_error (error, BD_LVM_ERROR, BD_LVM_ERROR_PARSE,
b3f87c
@@ -1039,6 +1041,7 @@ BDLVMPVdata** bd_lvm_pvs (GError **error) {
b3f87c
     if (pvs->len == 0) {
b3f87c
         g_set_error (error, BD_LVM_ERROR, BD_LVM_ERROR_PARSE,
b3f87c
                      "Failed to parse information about PVs");
b3f87c
+        g_ptr_array_free (pvs, TRUE);
b3f87c
         return NULL;
b3f87c
     }
b3f87c
 
b3f87c
@@ -1247,6 +1250,7 @@ BDLVMVGdata* bd_lvm_vginfo (const gchar *vg_name, GError **error) {
b3f87c
             if (table)
b3f87c
                 g_hash_table_destroy (table);
b3f87c
     }
b3f87c
+    g_strfreev (lines);
b3f87c
 
b3f87c
     /* getting here means no usable info was found */
b3f87c
     g_set_error (error, BD_LVM_ERROR, BD_LVM_ERROR_PARSE,
b3f87c
@@ -1312,6 +1316,7 @@ BDLVMVGdata** bd_lvm_vgs (GError **error) {
b3f87c
     if (vgs->len == 0) {
b3f87c
         g_set_error (error, BD_LVM_ERROR, BD_LVM_ERROR_PARSE,
b3f87c
                      "Failed to parse information about VGs");
b3f87c
+        g_ptr_array_free (vgs, TRUE);
b3f87c
         return NULL;
b3f87c
     }
b3f87c
 
b3f87c
@@ -1641,6 +1646,7 @@ BDLVMLVdata* bd_lvm_lvinfo (const gchar *vg_name, const gchar *lv_name, GError *
b3f87c
             if (table)
b3f87c
                 g_hash_table_destroy (table);
b3f87c
     }
b3f87c
+    g_strfreev (lines);
b3f87c
 
b3f87c
     /* getting here means no usable info was found */
b3f87c
     g_set_error (error, BD_LVM_ERROR, BD_LVM_ERROR_PARSE,
b3f87c
@@ -1713,6 +1719,7 @@ BDLVMLVdata** bd_lvm_lvs (const gchar *vg_name, GError **error) {
b3f87c
     if (lvs->len == 0) {
b3f87c
         g_set_error (error, BD_LVM_ERROR, BD_LVM_ERROR_PARSE,
b3f87c
                      "Failed to parse information about LVs");
b3f87c
+        g_ptr_array_free (lvs, FALSE);
b3f87c
         return NULL;
b3f87c
     }
b3f87c
 
b3f87c
-- 
b3f87c
2.21.0
b3f87c
b3f87c
b3f87c
From 552173cfcb77d9ed3476b55e0170627998081912 Mon Sep 17 00:00:00 2001
b3f87c
From: Tomas Bzatek <tbzatek@redhat.com>
b3f87c
Date: Wed, 24 Apr 2019 16:27:07 +0200
b3f87c
Subject: [PATCH 02/17] lvm: Use g_ptr_array_free() for creating lists
b3f87c
b3f87c
No need to allocate separate array and copy elements one by one, use
b3f87c
g_ptr_array_free() instead and only add the trailing NULL element as
b3f87c
a regular item.
b3f87c
b3f87c
This fixes leaks of the array shell.
b3f87c
---
b3f87c
 src/plugins/lvm.c | 88 ++++++++++++++++++++---------------------------
b3f87c
 1 file changed, 37 insertions(+), 51 deletions(-)
b3f87c
b3f87c
diff --git a/src/plugins/lvm.c b/src/plugins/lvm.c
b3f87c
index a23f8fd..c2f2bf8 100644
b3f87c
--- a/src/plugins/lvm.c
b3f87c
+++ b/src/plugins/lvm.c
b3f87c
@@ -1001,24 +1001,25 @@ BDLVMPVdata** bd_lvm_pvs (GError **error) {
b3f87c
     gchar **lines = NULL;
b3f87c
     gchar **lines_p = NULL;
b3f87c
     guint num_items;
b3f87c
-    GPtrArray *pvs = g_ptr_array_new ();
b3f87c
+    GPtrArray *pvs;
b3f87c
     BDLVMPVdata *pvdata = NULL;
b3f87c
-    BDLVMPVdata **ret = NULL;
b3f87c
-    guint64 i = 0;
b3f87c
 
b3f87c
-    success = call_lvm_and_capture_output (args, NULL, &output, error);
b3f87c
+    pvs = g_ptr_array_new ();
b3f87c
 
b3f87c
+    success = call_lvm_and_capture_output (args, NULL, &output, error);
b3f87c
     if (!success) {
b3f87c
         if (g_error_matches (*error, BD_UTILS_EXEC_ERROR, BD_UTILS_EXEC_ERROR_NOOUT)) {
b3f87c
             /* no output => no VGs, not an error */
b3f87c
             g_clear_error (error);
b3f87c
-            ret = g_new0 (BDLVMPVdata*, 1);
b3f87c
-            ret[0] = NULL;
b3f87c
-            return ret;
b3f87c
+            /* return an empty list */
b3f87c
+            g_ptr_array_add (pvs, NULL);
b3f87c
+            return (BDLVMPVdata **) g_ptr_array_free (pvs, FALSE);
b3f87c
         }
b3f87c
-        else
b3f87c
+        else {
b3f87c
             /* the error is already populated from the call */
b3f87c
+            g_ptr_array_free (pvs, TRUE);
b3f87c
             return NULL;
b3f87c
+        }
b3f87c
     }
b3f87c
 
b3f87c
     lines = g_strsplit (output, "\n", 0);
b3f87c
@@ -1045,15 +1046,9 @@ BDLVMPVdata** bd_lvm_pvs (GError **error) {
b3f87c
         return NULL;
b3f87c
     }
b3f87c
 
b3f87c
-    /* now create the return value -- NULL-terminated array of BDLVMPVdata */
b3f87c
-    ret = g_new0 (BDLVMPVdata*, pvs->len + 1);
b3f87c
-    for (i=0; i < pvs->len; i++)
b3f87c
-        ret[i] = (BDLVMPVdata*) g_ptr_array_index (pvs, i);
b3f87c
-    ret[i] = NULL;
b3f87c
-
b3f87c
-    g_ptr_array_free (pvs, FALSE);
b3f87c
-
b3f87c
-    return ret;
b3f87c
+    /* returning NULL-terminated array of BDLVMPVdata */
b3f87c
+    g_ptr_array_add (pvs, NULL);
b3f87c
+    return (BDLVMPVdata **) g_ptr_array_free (pvs, FALSE);
b3f87c
 }
b3f87c
 
b3f87c
 /**
b3f87c
@@ -1277,23 +1272,25 @@ BDLVMVGdata** bd_lvm_vgs (GError **error) {
b3f87c
     gchar **lines = NULL;
b3f87c
     gchar **lines_p = NULL;
b3f87c
     guint num_items;
b3f87c
-    GPtrArray *vgs = g_ptr_array_new ();
b3f87c
+    GPtrArray *vgs;
b3f87c
     BDLVMVGdata *vgdata = NULL;
b3f87c
-    BDLVMVGdata **ret = NULL;
b3f87c
-    guint64 i = 0;
b3f87c
+
b3f87c
+    vgs = g_ptr_array_new ();
b3f87c
 
b3f87c
     success = call_lvm_and_capture_output (args, NULL, &output, error);
b3f87c
     if (!success) {
b3f87c
         if (g_error_matches (*error, BD_UTILS_EXEC_ERROR, BD_UTILS_EXEC_ERROR_NOOUT)) {
b3f87c
             /* no output => no VGs, not an error */
b3f87c
             g_clear_error (error);
b3f87c
-            ret = g_new0 (BDLVMVGdata*, 1);
b3f87c
-            ret[0] = NULL;
b3f87c
-            return ret;
b3f87c
+            /* return an empty list */
b3f87c
+            g_ptr_array_add (vgs, NULL);
b3f87c
+            return (BDLVMVGdata **) g_ptr_array_free (vgs, FALSE);
b3f87c
         }
b3f87c
-        else
b3f87c
+        else {
b3f87c
             /* the error is already populated from the call */
b3f87c
+            g_ptr_array_free (vgs, TRUE);
b3f87c
             return NULL;
b3f87c
+       }
b3f87c
     }
b3f87c
 
b3f87c
     lines = g_strsplit (output, "\n", 0);
b3f87c
@@ -1320,15 +1317,9 @@ BDLVMVGdata** bd_lvm_vgs (GError **error) {
b3f87c
         return NULL;
b3f87c
     }
b3f87c
 
b3f87c
-    /* now create the return value -- NULL-terminated array of BDLVMVGdata */
b3f87c
-    ret = g_new0 (BDLVMVGdata*, vgs->len + 1);
b3f87c
-    for (i=0; i < vgs->len; i++)
b3f87c
-        ret[i] = (BDLVMVGdata*) g_ptr_array_index (vgs, i);
b3f87c
-    ret[i] = NULL;
b3f87c
-
b3f87c
-    g_ptr_array_free (vgs, FALSE);
b3f87c
-
b3f87c
-    return ret;
b3f87c
+    /* returning NULL-terminated array of BDLVMVGdata */
b3f87c
+    g_ptr_array_add (vgs, NULL);
b3f87c
+    return (BDLVMVGdata **) g_ptr_array_free (vgs, FALSE);
b3f87c
 }
b3f87c
 
b3f87c
 /**
b3f87c
@@ -1676,27 +1667,28 @@ BDLVMLVdata** bd_lvm_lvs (const gchar *vg_name, GError **error) {
b3f87c
     gchar **lines = NULL;
b3f87c
     gchar **lines_p = NULL;
b3f87c
     guint num_items;
b3f87c
-    GPtrArray *lvs = g_ptr_array_new ();
b3f87c
+    GPtrArray *lvs;
b3f87c
     BDLVMLVdata *lvdata = NULL;
b3f87c
-    BDLVMLVdata **ret = NULL;
b3f87c
-    guint64 i = 0;
b3f87c
+
b3f87c
+    lvs = g_ptr_array_new ();
b3f87c
 
b3f87c
     if (vg_name)
b3f87c
         args[9] = vg_name;
b3f87c
 
b3f87c
     success = call_lvm_and_capture_output (args, NULL, &output, error);
b3f87c
-
b3f87c
     if (!success) {
b3f87c
         if (g_error_matches (*error, BD_UTILS_EXEC_ERROR, BD_UTILS_EXEC_ERROR_NOOUT)) {
b3f87c
             /* no output => no LVs, not an error */
b3f87c
             g_clear_error (error);
b3f87c
-            ret = g_new0 (BDLVMLVdata*, 1);
b3f87c
-            ret[0] = NULL;
b3f87c
-            return ret;
b3f87c
+            /* return an empty list */
b3f87c
+            g_ptr_array_add (lvs, NULL);
b3f87c
+            return (BDLVMLVdata **) g_ptr_array_free (lvs, FALSE);
b3f87c
         }
b3f87c
-        else
b3f87c
+        else {
b3f87c
             /* the error is already populated from the call */
b3f87c
+            g_ptr_array_free (lvs, TRUE);
b3f87c
             return NULL;
b3f87c
+        }
b3f87c
     }
b3f87c
 
b3f87c
     lines = g_strsplit (output, "\n", 0);
b3f87c
@@ -1719,19 +1711,13 @@ BDLVMLVdata** bd_lvm_lvs (const gchar *vg_name, GError **error) {
b3f87c
     if (lvs->len == 0) {
b3f87c
         g_set_error (error, BD_LVM_ERROR, BD_LVM_ERROR_PARSE,
b3f87c
                      "Failed to parse information about LVs");
b3f87c
-        g_ptr_array_free (lvs, FALSE);
b3f87c
+        g_ptr_array_free (lvs, TRUE);
b3f87c
         return NULL;
b3f87c
     }
b3f87c
 
b3f87c
-    /* now create the return value -- NULL-terminated array of BDLVMLVdata */
b3f87c
-    ret = g_new0 (BDLVMLVdata*, lvs->len + 1);
b3f87c
-    for (i=0; i < lvs->len; i++)
b3f87c
-        ret[i] = (BDLVMLVdata*) g_ptr_array_index (lvs, i);
b3f87c
-    ret[i] = NULL;
b3f87c
-
b3f87c
-    g_ptr_array_free (lvs, FALSE);
b3f87c
-
b3f87c
-    return ret;
b3f87c
+    /* returning NULL-terminated array of BDLVMLVdata */
b3f87c
+    g_ptr_array_add (lvs, NULL);
b3f87c
+    return (BDLVMLVdata **) g_ptr_array_free (lvs, FALSE);
b3f87c
 }
b3f87c
 
b3f87c
 /**
b3f87c
-- 
b3f87c
2.21.0
b3f87c
b3f87c
b3f87c
From fa48a6e64181e7becadbad8202be6de1829b4b9b Mon Sep 17 00:00:00 2001
b3f87c
From: Tomas Bzatek <tbzatek@redhat.com>
b3f87c
Date: Wed, 24 Apr 2019 16:31:52 +0200
b3f87c
Subject: [PATCH 03/17] lvm: Fix leaking BDLVMPVdata.vg_uuid
b3f87c
b3f87c
---
b3f87c
 src/lib/plugin_apis/lvm.api | 2 ++
b3f87c
 src/plugins/lvm.c           | 2 ++
b3f87c
 2 files changed, 4 insertions(+)
b3f87c
b3f87c
diff --git a/src/lib/plugin_apis/lvm.api b/src/lib/plugin_apis/lvm.api
b3f87c
index ce47c51..bffe2ce 100644
b3f87c
--- a/src/lib/plugin_apis/lvm.api
b3f87c
+++ b/src/lib/plugin_apis/lvm.api
b3f87c
@@ -114,6 +114,7 @@ BDLVMPVdata* bd_lvm_pvdata_copy (BDLVMPVdata *data) {
b3f87c
     new_data->pv_size = data->pv_size;
b3f87c
     new_data->pe_start = data->pe_start;
b3f87c
     new_data->vg_name = g_strdup (data->vg_name);
b3f87c
+    new_data->vg_uuid = g_strdup (data->vg_uuid);
b3f87c
     new_data->vg_size = data->vg_size;
b3f87c
     new_data->vg_free = data->vg_free;
b3f87c
     new_data->vg_extent_size = data->vg_extent_size;
b3f87c
@@ -136,6 +137,7 @@ void bd_lvm_pvdata_free (BDLVMPVdata *data) {
b3f87c
     g_free (data->pv_name);
b3f87c
     g_free (data->pv_uuid);
b3f87c
     g_free (data->vg_name);
b3f87c
+    g_free (data->vg_uuid);
b3f87c
     g_free (data);
b3f87c
 }
b3f87c
 
b3f87c
diff --git a/src/plugins/lvm.c b/src/plugins/lvm.c
b3f87c
index c2f2bf8..a6d738d 100644
b3f87c
--- a/src/plugins/lvm.c
b3f87c
+++ b/src/plugins/lvm.c
b3f87c
@@ -63,6 +63,7 @@ BDLVMPVdata* bd_lvm_pvdata_copy (BDLVMPVdata *data) {
b3f87c
     new_data->pv_size = data->pv_size;
b3f87c
     new_data->pe_start = data->pe_start;
b3f87c
     new_data->vg_name = g_strdup (data->vg_name);
b3f87c
+    new_data->vg_uuid = g_strdup (data->vg_uuid);
b3f87c
     new_data->vg_size = data->vg_size;
b3f87c
     new_data->vg_free = data->vg_free;
b3f87c
     new_data->vg_extent_size = data->vg_extent_size;
b3f87c
@@ -80,6 +81,7 @@ void bd_lvm_pvdata_free (BDLVMPVdata *data) {
b3f87c
     g_free (data->pv_name);
b3f87c
     g_free (data->pv_uuid);
b3f87c
     g_free (data->vg_name);
b3f87c
+    g_free (data->vg_uuid);
b3f87c
     g_free (data);
b3f87c
 }
b3f87c
 
b3f87c
-- 
b3f87c
2.21.0
b3f87c
b3f87c
b3f87c
From 1b44335a35d8d886f3a251f1c51d1f1039651d4e Mon Sep 17 00:00:00 2001
b3f87c
From: Tomas Bzatek <tbzatek@redhat.com>
b3f87c
Date: Wed, 24 Apr 2019 18:36:21 +0200
b3f87c
Subject: [PATCH 04/17] exec: Fix some memory leaks
b3f87c
b3f87c
---
b3f87c
 src/utils/exec.c | 10 ++++++++--
b3f87c
 1 file changed, 8 insertions(+), 2 deletions(-)
b3f87c
b3f87c
diff --git a/src/utils/exec.c b/src/utils/exec.c
b3f87c
index 28635a1..b1ca436 100644
b3f87c
--- a/src/utils/exec.c
b3f87c
+++ b/src/utils/exec.c
b3f87c
@@ -228,8 +228,12 @@ gboolean bd_utils_exec_and_report_status_error (const gchar **argv, const BDExtr
b3f87c
     log_out (task_id, stdout_data, stderr_data);
b3f87c
     log_done (task_id, *status);
b3f87c
 
b3f87c
+    g_free (args);
b3f87c
+
b3f87c
     if (!success) {
b3f87c
         /* error is already populated from the call */
b3f87c
+        g_free (stdout_data);
b3f87c
+        g_free (stderr_data);
b3f87c
         return FALSE;
b3f87c
     }
b3f87c
 
b3f87c
@@ -247,7 +251,6 @@ gboolean bd_utils_exec_and_report_status_error (const gchar **argv, const BDExtr
b3f87c
         return FALSE;
b3f87c
     }
b3f87c
 
b3f87c
-    g_free (args);
b3f87c
     g_free (stdout_data);
b3f87c
     g_free (stderr_data);
b3f87c
     return TRUE;
b3f87c
@@ -398,14 +401,17 @@ gboolean bd_utils_exec_and_report_progress (const gchar **argv, const BDExtraArg
b3f87c
                                     G_SPAWN_DEFAULT|G_SPAWN_SEARCH_PATH|G_SPAWN_DO_NOT_REAP_CHILD,
b3f87c
                                     NULL, NULL, &pid, NULL, &out_fd, &err_fd, error);
b3f87c
 
b3f87c
-    if (!ret)
b3f87c
+    if (!ret) {
b3f87c
         /* error is already populated */
b3f87c
+        g_free (args);
b3f87c
         return FALSE;
b3f87c
+    }
b3f87c
 
b3f87c
     args_str = g_strjoinv (" ", args ? (gchar **) args : (gchar **) argv);
b3f87c
     msg = g_strdup_printf ("Started '%s'", args_str);
b3f87c
     progress_id = bd_utils_report_started (msg);
b3f87c
     g_free (args_str);
b3f87c
+    g_free (args);
b3f87c
     g_free (msg);
b3f87c
 
b3f87c
     out_pipe = g_io_channel_unix_new (out_fd);
b3f87c
-- 
b3f87c
2.21.0
b3f87c
b3f87c
b3f87c
From e943381bf7c1aeb27f6e308f95e3f64436f25247 Mon Sep 17 00:00:00 2001
b3f87c
From: Tomas Bzatek <tbzatek@redhat.com>
b3f87c
Date: Thu, 9 May 2019 15:39:24 +0200
b3f87c
Subject: [PATCH 05/17] mdraid: Fix g_strsplit() leaks
b3f87c
b3f87c
---
b3f87c
 src/plugins/mdraid.c | 5 +++++
b3f87c
 1 file changed, 5 insertions(+)
b3f87c
b3f87c
diff --git a/src/plugins/mdraid.c b/src/plugins/mdraid.c
b3f87c
index 6465dfe..178379e 100644
b3f87c
--- a/src/plugins/mdraid.c
b3f87c
+++ b/src/plugins/mdraid.c
b3f87c
@@ -255,10 +255,15 @@ static GHashTable* parse_mdadm_vars (const gchar *str, const gchar *item_sep, co
b3f87c
                     /* mdadm --examine output for a set being migrated */
b3f87c
                     vals = g_strsplit (key_val[1], "<--", 2);
b3f87c
                     g_hash_table_insert (table, g_strstrip (key_val[0]), g_strstrip (vals[0]));
b3f87c
+                    g_free (key_val[1]);
b3f87c
                     g_free (vals[1]);
b3f87c
+                    g_free (vals);
b3f87c
                 } else {
b3f87c
                     g_hash_table_insert (table, g_strstrip (key_val[0]), g_strstrip (key_val[1]));
b3f87c
                 }
b3f87c
+                g_free (key_val);
b3f87c
+            } else {
b3f87c
+                g_strfreev (key_val);
b3f87c
             }
b3f87c
             (*num_items)++;
b3f87c
         } else
b3f87c
-- 
b3f87c
2.21.0
b3f87c
b3f87c
b3f87c
From 21fba5737901b6fa82b3c04bb9058ac650b8e54d Mon Sep 17 00:00:00 2001
b3f87c
From: Tomas Bzatek <tbzatek@redhat.com>
b3f87c
Date: Thu, 9 May 2019 15:39:39 +0200
b3f87c
Subject: [PATCH 06/17] s390: Fix g_strsplit() leaks
b3f87c
b3f87c
---
b3f87c
 src/plugins/s390.c | 8 ++------
b3f87c
 1 file changed, 2 insertions(+), 6 deletions(-)
b3f87c
b3f87c
diff --git a/src/plugins/s390.c b/src/plugins/s390.c
b3f87c
index dcb5bc9..ac12b04 100644
b3f87c
--- a/src/plugins/s390.c
b3f87c
+++ b/src/plugins/s390.c
b3f87c
@@ -775,8 +775,6 @@ gboolean bd_s390_zfcp_scsi_offline(const gchar *devno, const gchar *wwpn, const
b3f87c
     gchar *hba_path = NULL;
b3f87c
     gchar *wwpn_path = NULL;
b3f87c
     gchar *lun_path = NULL;
b3f87c
-    gchar *host = NULL;
b3f87c
-    gchar *fcplun = NULL;
b3f87c
     gchar *scsidev = NULL;
b3f87c
     gchar *fcpsysfs = NULL;
b3f87c
     gchar *scsidel = NULL;
b3f87c
@@ -804,13 +802,11 @@ gboolean bd_s390_zfcp_scsi_offline(const gchar *devno, const gchar *wwpn, const
b3f87c
         /* tokenize line and assign certain values we'll need later */
b3f87c
         tokens = g_strsplit (line, delim, 8);
b3f87c
 
b3f87c
-        host = tokens[1];
b3f87c
-        fcplun = tokens[7];
b3f87c
-
b3f87c
-        scsidev = g_strdup_printf ("%s:%s:%s:%s", host + 4, channel, devid, fcplun);
b3f87c
+        scsidev = g_strdup_printf ("%s:%s:%s:%s", tokens[1] /* host */ + 4, channel, devid, tokens[7] /* fcplun */);
b3f87c
         scsidev = g_strchomp (scsidev);
b3f87c
         fcpsysfs = g_strdup_printf ("%s/%s", scsidevsysfs, scsidev);
b3f87c
         fcpsysfs = g_strchomp (fcpsysfs);
b3f87c
+        g_strfreev (tokens);
b3f87c
 
b3f87c
         /* get HBA path value (same as device number) */
b3f87c
         hba_path = g_strdup_printf ("%s/hba_id", fcpsysfs);
b3f87c
-- 
b3f87c
2.21.0
b3f87c
b3f87c
b3f87c
From 9e751457a983a4ba07fcd285b15af29aad051b25 Mon Sep 17 00:00:00 2001
b3f87c
From: Tomas Bzatek <tbzatek@redhat.com>
b3f87c
Date: Thu, 9 May 2019 16:10:11 +0200
b3f87c
Subject: [PATCH 07/17] ext: Fix g_strsplit() leaks
b3f87c
b3f87c
---
b3f87c
 src/plugins/fs/ext.c | 1 +
b3f87c
 1 file changed, 1 insertion(+)
b3f87c
b3f87c
diff --git a/src/plugins/fs/ext.c b/src/plugins/fs/ext.c
b3f87c
index 03ac1c5..98f2861 100644
b3f87c
--- a/src/plugins/fs/ext.c
b3f87c
+++ b/src/plugins/fs/ext.c
b3f87c
@@ -534,6 +534,7 @@ static GHashTable* parse_output_vars (const gchar *str, const gchar *item_sep, c
b3f87c
         if (g_strv_length (key_val) == 2) {
b3f87c
             /* we only want to process valid lines (with the separator) */
b3f87c
             g_hash_table_insert (table, g_strstrip (key_val[0]), g_strstrip (key_val[1]));
b3f87c
+            g_free (key_val);
b3f87c
             (*num_items)++;
b3f87c
         } else
b3f87c
             /* invalid line, just free key_val */
b3f87c
-- 
b3f87c
2.21.0
b3f87c
b3f87c
b3f87c
From bb774818d210f7159ed0b7db11c1a8490ac7ee0f Mon Sep 17 00:00:00 2001
b3f87c
From: Tomas Bzatek <tbzatek@redhat.com>
b3f87c
Date: Thu, 9 May 2019 16:15:36 +0200
b3f87c
Subject: [PATCH 08/17] ext: Fix g_match_info_fetch() leaks
b3f87c
b3f87c
---
b3f87c
 src/plugins/fs/ext.c | 16 +++++++++++++---
b3f87c
 1 file changed, 13 insertions(+), 3 deletions(-)
b3f87c
b3f87c
diff --git a/src/plugins/fs/ext.c b/src/plugins/fs/ext.c
b3f87c
index 98f2861..91b0ff5 100644
b3f87c
--- a/src/plugins/fs/ext.c
b3f87c
+++ b/src/plugins/fs/ext.c
b3f87c
@@ -96,13 +96,23 @@ static gint8 filter_line_fsck (const gchar * line, guint8 total_stages, GError *
b3f87c
         guint8 stage;
b3f87c
         gint64 val_cur;
b3f87c
         gint64 val_total;
b3f87c
+        gchar *s;
b3f87c
 
b3f87c
         /* The output_regex ensures we have a number in these matches, so we can skip
b3f87c
          * tests for conversion errors.
b3f87c
          */
b3f87c
-        stage = (guint8) g_ascii_strtoull (g_match_info_fetch (match_info, 1), (char **)NULL, 10);
b3f87c
-        val_cur = g_ascii_strtoll (g_match_info_fetch (match_info, 2), (char **)NULL, 10);
b3f87c
-        val_total = g_ascii_strtoll (g_match_info_fetch (match_info, 3), (char **)NULL, 10);
b3f87c
+        s = g_match_info_fetch (match_info, 1);
b3f87c
+        stage = (guint8) g_ascii_strtoull (s, (char **)NULL, 10);
b3f87c
+        g_free (s);
b3f87c
+
b3f87c
+        s = g_match_info_fetch (match_info, 2);
b3f87c
+        val_cur = g_ascii_strtoll (s, (char **)NULL, 10);
b3f87c
+        g_free (s);
b3f87c
+
b3f87c
+        s = g_match_info_fetch (match_info, 3);
b3f87c
+        val_total = g_ascii_strtoll (s, (char **)NULL, 10);
b3f87c
+        g_free (s);
b3f87c
+
b3f87c
         perc = compute_percents (stage, total_stages, val_cur, val_total);
b3f87c
     } else {
b3f87c
         g_match_info_free (match_info);
b3f87c
-- 
b3f87c
2.21.0
b3f87c
b3f87c
b3f87c
From 70779be74507b5e8a3d4d6c5a226906186844f0b Mon Sep 17 00:00:00 2001
b3f87c
From: Tomas Bzatek <tbzatek@redhat.com>
b3f87c
Date: Thu, 9 May 2019 16:16:06 +0200
b3f87c
Subject: [PATCH 09/17] kbd: Fix g_match_info_fetch() leaks
b3f87c
b3f87c
---
b3f87c
 src/plugins/kbd.c | 6 +++++-
b3f87c
 1 file changed, 5 insertions(+), 1 deletion(-)
b3f87c
b3f87c
diff --git a/src/plugins/kbd.c b/src/plugins/kbd.c
b3f87c
index 33208c7..a2908ec 100644
b3f87c
--- a/src/plugins/kbd.c
b3f87c
+++ b/src/plugins/kbd.c
b3f87c
@@ -782,7 +782,11 @@ gboolean bd_kbd_bcache_create (const gchar *backing_device, const gchar *cache_d
b3f87c
     for (i=0; lines[i] && n < 2; i++) {
b3f87c
         success = g_regex_match (regex, lines[i], 0, &match_info);
b3f87c
         if (success) {
b3f87c
-            strncpy (device_uuid[n], g_match_info_fetch (match_info, 1), 63);
b3f87c
+            gchar *s;
b3f87c
+
b3f87c
+            s = g_match_info_fetch (match_info, 1);
b3f87c
+            strncpy (device_uuid[n], s, 63);
b3f87c
+            g_free (s);
b3f87c
             device_uuid[n][63] = '\0';
b3f87c
             n++;
b3f87c
             g_match_info_free (match_info);
b3f87c
-- 
b3f87c
2.21.0
b3f87c
b3f87c
b3f87c
From 9c364521d3a7b0b8c04061003f16d73eee8778c8 Mon Sep 17 00:00:00 2001
b3f87c
From: Tomas Bzatek <tbzatek@redhat.com>
b3f87c
Date: Thu, 9 May 2019 17:16:37 +0200
b3f87c
Subject: [PATCH 10/17] part: Fix leaking objects
b3f87c
b3f87c
---
b3f87c
 src/plugins/part.c | 2 ++
b3f87c
 1 file changed, 2 insertions(+)
b3f87c
b3f87c
diff --git a/src/plugins/part.c b/src/plugins/part.c
b3f87c
index 31c6591..cf62366 100644
b3f87c
--- a/src/plugins/part.c
b3f87c
+++ b/src/plugins/part.c
b3f87c
@@ -913,6 +913,8 @@ static gboolean resize_part (PedPartition *part, PedDevice *dev, PedDisk *disk,
b3f87c
         return FALSE;
b3f87c
     }
b3f87c
 
b3f87c
+    ped_geometry_destroy (geom);
b3f87c
+    ped_constraint_destroy (constr);
b3f87c
     finish_alignment_constraint (disk, orig_flag_state);
b3f87c
     return TRUE;
b3f87c
 }
b3f87c
-- 
b3f87c
2.21.0
b3f87c
b3f87c
b3f87c
From 2d24ea310fe65b020d7ef3450057bde1383910aa Mon Sep 17 00:00:00 2001
b3f87c
From: Tomas Bzatek <tbzatek@redhat.com>
b3f87c
Date: Thu, 9 May 2019 17:17:01 +0200
b3f87c
Subject: [PATCH 11/17] ext: Fix leaking string
b3f87c
b3f87c
---
b3f87c
 src/plugins/fs/ext.c | 4 +++-
b3f87c
 1 file changed, 3 insertions(+), 1 deletion(-)
b3f87c
b3f87c
diff --git a/src/plugins/fs/ext.c b/src/plugins/fs/ext.c
b3f87c
index 91b0ff5..fbec90a 100644
b3f87c
--- a/src/plugins/fs/ext.c
b3f87c
+++ b/src/plugins/fs/ext.c
b3f87c
@@ -560,8 +560,10 @@ static BDFSExtInfo* get_ext_info_from_table (GHashTable *table, gboolean free_ta
b3f87c
     gchar *value = NULL;
b3f87c
 
b3f87c
     ret->label = g_strdup ((gchar*) g_hash_table_lookup (table, "Filesystem volume name"));
b3f87c
-    if ((!ret->label) || (g_strcmp0 (ret->label, "<none>") == 0))
b3f87c
+    if (!ret->label || g_strcmp0 (ret->label, "<none>") == 0) {
b3f87c
+        g_free (ret->label);
b3f87c
         ret->label = g_strdup ("");
b3f87c
+    }
b3f87c
     ret->uuid = g_strdup ((gchar*) g_hash_table_lookup (table, "Filesystem UUID"));
b3f87c
     ret->state = g_strdup ((gchar*) g_hash_table_lookup (table, "Filesystem state"));
b3f87c
 
b3f87c
-- 
b3f87c
2.21.0
b3f87c
b3f87c
b3f87c
From 957b4b84eeaacab612ea5e267dc37b194f9d65f3 Mon Sep 17 00:00:00 2001
b3f87c
From: Tomas Bzatek <tbzatek@redhat.com>
b3f87c
Date: Thu, 9 May 2019 18:23:46 +0200
b3f87c
Subject: [PATCH 12/17] part: Fix leaking string in args
b3f87c
b3f87c
---
b3f87c
 src/plugins/part.c | 5 ++---
b3f87c
 1 file changed, 2 insertions(+), 3 deletions(-)
b3f87c
b3f87c
diff --git a/src/plugins/part.c b/src/plugins/part.c
b3f87c
index cf62366..8b2285f 100644
b3f87c
--- a/src/plugins/part.c
b3f87c
+++ b/src/plugins/part.c
b3f87c
@@ -373,10 +373,9 @@ static gchar* get_part_type_guid_and_gpt_flags (const gchar *device, int part_nu
b3f87c
 
b3f87c
     args[1] = g_strdup_printf ("-i%d", part_num);
b3f87c
     success = bd_utils_exec_and_capture_output (args, NULL, &output, error);
b3f87c
-    if (!success) {
b3f87c
-        g_free ((gchar *) args[1]);
b3f87c
+    g_free ((gchar *) args[1]);
b3f87c
+    if (!success)
b3f87c
         return FALSE;
b3f87c
-    }
b3f87c
 
b3f87c
     lines = g_strsplit (output, "\n", 0);
b3f87c
     g_free (output);
b3f87c
-- 
b3f87c
2.21.0
b3f87c
b3f87c
b3f87c
From 6613cc6b28766607801f95b54bcbc872de02412b Mon Sep 17 00:00:00 2001
b3f87c
From: Tomas Bzatek <tbzatek@redhat.com>
b3f87c
Date: Thu, 16 May 2019 12:46:56 +0200
b3f87c
Subject: [PATCH 13/17] mdraid: Fix leaking error
b3f87c
b3f87c
---
b3f87c
 src/plugins/mdraid.c | 5 ++---
b3f87c
 1 file changed, 2 insertions(+), 3 deletions(-)
b3f87c
b3f87c
diff --git a/src/plugins/mdraid.c b/src/plugins/mdraid.c
b3f87c
index 178379e..8f5b2ca 100644
b3f87c
--- a/src/plugins/mdraid.c
b3f87c
+++ b/src/plugins/mdraid.c
b3f87c
@@ -178,7 +178,7 @@ gboolean bd_md_check_deps (void) {
b3f87c
     }
b3f87c
 
b3f87c
     if (!ret)
b3f87c
-        g_warning("Cannot load the MDRAID plugin");
b3f87c
+        g_warning ("Cannot load the MDRAID plugin");
b3f87c
 
b3f87c
     return ret;
b3f87c
 }
b3f87c
@@ -357,8 +357,7 @@ static BDMDExamineData* get_examine_data_from_table (GHashTable *table, gboolean
b3f87c
         }
b3f87c
 
b3f87c
         if (bs_error) {
b3f87c
-            g_set_error (error, BD_MD_ERROR, BD_MD_ERROR_PARSE,
b3f87c
-                         "Failed to parse chunk size from mdexamine data: %s", bs_error->msg);
b3f87c
+            g_warning ("get_examine_data_from_table(): Failed to parse chunk size from mdexamine data: %s", bs_error->msg);
b3f87c
             bs_clear_error (&bs_error);
b3f87c
         }
b3f87c
     } else
b3f87c
-- 
b3f87c
2.21.0
b3f87c
b3f87c
b3f87c
From 9ad488f460f65abded312be4b5cf1f00f9fc8aa5 Mon Sep 17 00:00:00 2001
b3f87c
From: Tomas Bzatek <tbzatek@redhat.com>
b3f87c
Date: Thu, 16 May 2019 12:54:09 +0200
b3f87c
Subject: [PATCH 14/17] mdraid: Mark 'error' arg in
b3f87c
 get_examine_data_from_table() as unused
b3f87c
b3f87c
---
b3f87c
 src/plugins/mdraid.c | 2 +-
b3f87c
 1 file changed, 1 insertion(+), 1 deletion(-)
b3f87c
b3f87c
diff --git a/src/plugins/mdraid.c b/src/plugins/mdraid.c
b3f87c
index 8f5b2ca..a333e6f 100644
b3f87c
--- a/src/plugins/mdraid.c
b3f87c
+++ b/src/plugins/mdraid.c
b3f87c
@@ -275,7 +275,7 @@ static GHashTable* parse_mdadm_vars (const gchar *str, const gchar *item_sep, co
b3f87c
     return table;
b3f87c
 }
b3f87c
 
b3f87c
-static BDMDExamineData* get_examine_data_from_table (GHashTable *table, gboolean free_table, GError **error) {
b3f87c
+static BDMDExamineData* get_examine_data_from_table (GHashTable *table, gboolean free_table, G_GNUC_UNUSED GError **error) {
b3f87c
     BDMDExamineData *data = g_new0 (BDMDExamineData, 1);
b3f87c
     gchar *value = NULL;
b3f87c
     gchar *first_space = NULL;
b3f87c
-- 
b3f87c
2.21.0
b3f87c
b3f87c
b3f87c
From eaa07958b928141783202967cbae0e86fdee488d Mon Sep 17 00:00:00 2001
b3f87c
From: Tomas Bzatek <tbzatek@redhat.com>
b3f87c
Date: Thu, 16 May 2019 12:55:50 +0200
b3f87c
Subject: [PATCH 15/17] mdraid: Fix leaking BDMDExamineData.metadata
b3f87c
b3f87c
---
b3f87c
 src/plugins/mdraid.c | 1 +
b3f87c
 1 file changed, 1 insertion(+)
b3f87c
b3f87c
diff --git a/src/plugins/mdraid.c b/src/plugins/mdraid.c
b3f87c
index a333e6f..74af744 100644
b3f87c
--- a/src/plugins/mdraid.c
b3f87c
+++ b/src/plugins/mdraid.c
b3f87c
@@ -1049,6 +1049,7 @@ BDMDExamineData* bd_md_examine (const gchar *device, GError **error) {
b3f87c
     }
b3f87c
 
b3f87c
     /* try to get metadata version from the output (may be missing) */
b3f87c
+    g_free (ret->metadata);
b3f87c
     value = (gchar*) g_hash_table_lookup (table, "metadata");
b3f87c
     if (value)
b3f87c
         ret->metadata = g_strdup (value);
b3f87c
-- 
b3f87c
2.21.0
b3f87c
b3f87c
b3f87c
From 6b384841027c22f3fac28dd295e8a6124d4d7498 Mon Sep 17 00:00:00 2001
b3f87c
From: Tomas Bzatek <tbzatek@redhat.com>
b3f87c
Date: Thu, 16 May 2019 17:40:51 +0200
b3f87c
Subject: [PATCH 16/17] btrfs: Fix number of memory leaks
b3f87c
b3f87c
---
b3f87c
 src/plugins/btrfs.c | 40 ++++++++++++++++++++++------------------
b3f87c
 1 file changed, 22 insertions(+), 18 deletions(-)
b3f87c
b3f87c
diff --git a/src/plugins/btrfs.c b/src/plugins/btrfs.c
b3f87c
index c76ea3f..8a2c81a 100644
b3f87c
--- a/src/plugins/btrfs.c
b3f87c
+++ b/src/plugins/btrfs.c
b3f87c
@@ -619,9 +619,7 @@ BDBtrfsDeviceInfo** bd_btrfs_list_devices (const gchar *device, GError **error)
b3f87c
                                   "path[ \\t]+(?P<path>\\S+)\n";
b3f87c
     GRegex *regex = NULL;
b3f87c
     GMatchInfo *match_info = NULL;
b3f87c
-    guint8 i = 0;
b3f87c
-    GPtrArray *dev_infos = g_ptr_array_new ();
b3f87c
-    BDBtrfsDeviceInfo** ret = NULL;
b3f87c
+    GPtrArray *dev_infos;
b3f87c
 
b3f87c
     if (!check_deps (&avail_deps, DEPS_BTRFS_MASK, deps, DEPS_LAST, &deps_check_lock, error) ||
b3f87c
         !check_module_deps (&avail_module_deps, MODULE_DEPS_BTRFS_MASK, module_deps, MODULE_DEPS_LAST, &deps_check_lock, error))
b3f87c
@@ -635,13 +633,16 @@ BDBtrfsDeviceInfo** bd_btrfs_list_devices (const gchar *device, GError **error)
b3f87c
     }
b3f87c
 
b3f87c
     success = bd_utils_exec_and_capture_output (argv, NULL, &output, error);
b3f87c
-    if (!success)
b3f87c
+    if (!success) {
b3f87c
+        g_regex_unref (regex);
b3f87c
         /* error is already populated from the previous call */
b3f87c
         return NULL;
b3f87c
+    }
b3f87c
 
b3f87c
     lines = g_strsplit (output, "\n", 0);
b3f87c
     g_free (output);
b3f87c
 
b3f87c
+    dev_infos = g_ptr_array_new ();
b3f87c
     for (line_p = lines; *line_p; line_p++) {
b3f87c
         success = g_regex_match (regex, *line_p, 0, &match_info);
b3f87c
         if (!success) {
b3f87c
@@ -654,21 +655,16 @@ BDBtrfsDeviceInfo** bd_btrfs_list_devices (const gchar *device, GError **error)
b3f87c
     }
b3f87c
 
b3f87c
     g_strfreev (lines);
b3f87c
+    g_regex_unref (regex);
b3f87c
 
b3f87c
     if (dev_infos->len == 0) {
b3f87c
         g_set_error (error, BD_BTRFS_ERROR, BD_BTRFS_ERROR_PARSE, "Failed to parse information about devices");
b3f87c
+        g_ptr_array_free (dev_infos, TRUE);
b3f87c
         return NULL;
b3f87c
     }
b3f87c
 
b3f87c
-    /* now create the return value -- NULL-terminated array of BDBtrfsDeviceInfo */
b3f87c
-    ret = g_new0 (BDBtrfsDeviceInfo*, dev_infos->len + 1);
b3f87c
-    for (i=0; i < dev_infos->len; i++)
b3f87c
-        ret[i] = (BDBtrfsDeviceInfo*) g_ptr_array_index (dev_infos, i);
b3f87c
-    ret[i] = NULL;
b3f87c
-
b3f87c
-    g_ptr_array_free (dev_infos, FALSE);
b3f87c
-
b3f87c
-    return ret;
b3f87c
+    g_ptr_array_add (dev_infos, NULL);
b3f87c
+    return (BDBtrfsDeviceInfo **) g_ptr_array_free (dev_infos, FALSE);
b3f87c
 }
b3f87c
 
b3f87c
 /**
b3f87c
@@ -700,7 +696,7 @@ BDBtrfsSubvolumeInfo** bd_btrfs_list_subvolumes (const gchar *mountpoint, gboole
b3f87c
     guint64 i = 0;
b3f87c
     guint64 y = 0;
b3f87c
     guint64 next_sorted_idx = 0;
b3f87c
-    GPtrArray *subvol_infos = g_ptr_array_new ();
b3f87c
+    GPtrArray *subvol_infos;
b3f87c
     BDBtrfsSubvolumeInfo* item = NULL;
b3f87c
     BDBtrfsSubvolumeInfo* swap_item = NULL;
b3f87c
     BDBtrfsSubvolumeInfo** ret = NULL;
b3f87c
@@ -724,11 +720,11 @@ BDBtrfsSubvolumeInfo** bd_btrfs_list_subvolumes (const gchar *mountpoint, gboole
b3f87c
 
b3f87c
     success = bd_utils_exec_and_capture_output (argv, NULL, &output, error);
b3f87c
     if (!success) {
b3f87c
+        g_regex_unref (regex);
b3f87c
         if (g_error_matches (*error,  BD_UTILS_EXEC_ERROR, BD_UTILS_EXEC_ERROR_NOOUT)) {
b3f87c
             /* no output -> no subvolumes */
b3f87c
-            ret = g_new0 (BDBtrfsSubvolumeInfo*, 1);
b3f87c
             g_clear_error (error);
b3f87c
-            return ret;
b3f87c
+            return g_new0 (BDBtrfsSubvolumeInfo*, 1);
b3f87c
         } else {
b3f87c
             /* error is already populated from the call above or simply no output*/
b3f87c
             return NULL;
b3f87c
@@ -738,6 +734,7 @@ BDBtrfsSubvolumeInfo** bd_btrfs_list_subvolumes (const gchar *mountpoint, gboole
b3f87c
     lines = g_strsplit (output, "\n", 0);
b3f87c
     g_free (output);
b3f87c
 
b3f87c
+    subvol_infos = g_ptr_array_new ();
b3f87c
     for (line_p = lines; *line_p; line_p++) {
b3f87c
         success = g_regex_match (regex, *line_p, 0, &match_info);
b3f87c
         if (!success) {
b3f87c
@@ -750,9 +747,11 @@ BDBtrfsSubvolumeInfo** bd_btrfs_list_subvolumes (const gchar *mountpoint, gboole
b3f87c
     }
b3f87c
 
b3f87c
     g_strfreev (lines);
b3f87c
+    g_regex_unref (regex);
b3f87c
 
b3f87c
     if (subvol_infos->len == 0) {
b3f87c
         g_set_error (error, BD_BTRFS_ERROR, BD_BTRFS_ERROR_PARSE, "Failed to parse information about subvolumes");
b3f87c
+        g_ptr_array_free (subvol_infos, TRUE);
b3f87c
         return NULL;
b3f87c
     }
b3f87c
 
b3f87c
@@ -828,21 +827,26 @@ BDBtrfsFilesystemInfo* bd_btrfs_filesystem_info (const gchar *device, GError **e
b3f87c
     }
b3f87c
 
b3f87c
     success = bd_utils_exec_and_capture_output (argv, NULL, &output, error);
b3f87c
-    if (!success)
b3f87c
+    if (!success) {
b3f87c
         /* error is already populated from the call above or just empty
b3f87c
            output */
b3f87c
+        g_regex_unref (regex);
b3f87c
         return NULL;
b3f87c
+    }
b3f87c
 
b3f87c
     success = g_regex_match (regex, output, 0, &match_info);
b3f87c
     if (!success) {
b3f87c
         g_regex_unref (regex);
b3f87c
         g_match_info_free (match_info);
b3f87c
+        g_free (output);
b3f87c
         return NULL;
b3f87c
     }
b3f87c
 
b3f87c
-    g_regex_unref (regex);
b3f87c
     ret = get_filesystem_info_from_match (match_info);
b3f87c
     g_match_info_free (match_info);
b3f87c
+    g_regex_unref (regex);
b3f87c
+
b3f87c
+    g_free (output);
b3f87c
 
b3f87c
     return ret;
b3f87c
 }
b3f87c
-- 
b3f87c
2.21.0
b3f87c
b3f87c
b3f87c
From 6f0ec1d90584c59da9bb5f22f692b7d5ebfb2708 Mon Sep 17 00:00:00 2001
b3f87c
From: Tomas Bzatek <tbzatek@redhat.com>
b3f87c
Date: Fri, 17 May 2019 16:09:50 +0200
b3f87c
Subject: [PATCH 17/17] module: Fix libkmod related leak
b3f87c
b3f87c
---
b3f87c
 src/utils/module.c | 7 ++++---
b3f87c
 1 file changed, 4 insertions(+), 3 deletions(-)
b3f87c
b3f87c
diff --git a/src/utils/module.c b/src/utils/module.c
b3f87c
index 0709633..cdad960 100644
b3f87c
--- a/src/utils/module.c
b3f87c
+++ b/src/utils/module.c
b3f87c
@@ -60,7 +60,7 @@ gboolean bd_utils_have_kernel_module (const gchar *module_name, GError **error)
b3f87c
         return FALSE;
b3f87c
     }
b3f87c
     /* prevent libkmod from spamming our STDERR */
b3f87c
-    kmod_set_log_priority(ctx, LOG_CRIT);
b3f87c
+    kmod_set_log_priority (ctx, LOG_CRIT);
b3f87c
 
b3f87c
     ret = kmod_module_new_from_name (ctx, module_name, &mod);
b3f87c
     if (ret < 0) {
b3f87c
@@ -106,7 +106,7 @@ gboolean bd_utils_load_kernel_module (const gchar *module_name, const gchar *opt
b3f87c
         return FALSE;
b3f87c
     }
b3f87c
     /* prevent libkmod from spamming our STDERR */
b3f87c
-    kmod_set_log_priority(ctx, LOG_CRIT);
b3f87c
+    kmod_set_log_priority (ctx, LOG_CRIT);
b3f87c
 
b3f87c
     ret = kmod_module_new_from_name (ctx, module_name, &mod);
b3f87c
     if (ret < 0) {
b3f87c
@@ -169,7 +169,7 @@ gboolean bd_utils_unload_kernel_module (const gchar *module_name, GError **error
b3f87c
         return FALSE;
b3f87c
     }
b3f87c
     /* prevent libkmod from spamming our STDERR */
b3f87c
-    kmod_set_log_priority(ctx, LOG_CRIT);
b3f87c
+    kmod_set_log_priority (ctx, LOG_CRIT);
b3f87c
 
b3f87c
     ret = kmod_module_new_from_loaded (ctx, &list);
b3f87c
     if (ret < 0) {
b3f87c
@@ -187,6 +187,7 @@ gboolean bd_utils_unload_kernel_module (const gchar *module_name, GError **error
b3f87c
         else
b3f87c
             kmod_module_unref (mod);
b3f87c
     }
b3f87c
+    kmod_module_unref_list (list);
b3f87c
 
b3f87c
     if (!found) {
b3f87c
         g_set_error (error, BD_UTILS_MODULE_ERROR, BD_UTILS_MODULE_ERROR_NOEXIST,
b3f87c
-- 
b3f87c
2.21.0
b3f87c