From 2b0b9b59aee28c3ef623f1b2bf7960ad49a4d874 Mon Sep 17 00:00:00 2001 From: Zhiqiang Liu Date: Fri, 30 Oct 2020 15:41:17 +0800 Subject: [PATCH] libblockdev: backport upstream patches - epoch2 to fix several problems backport upstream patches - epoch2 to fix several problems Signed-off-by: Zhiqiang Liu --- ...return-values-in-bd_fs_ntfs_get_info.patch | 52 +++++++++++++++++++ ...-return-values-in-bd_fs_xfs_get_info.patch | 52 +++++++++++++++++++ ...omparing-DM-RAID-member-devices-UUID.patch | 30 +++++++++++ ...ak-in-the-DM-plugin-and-DM-logging-r.patch | 30 +++++++++++ 0011-fs-Fix-memory-leak.patch | 29 +++++++++++ 0012-kbd-Fix-memory-leak.patch | 24 +++++++++ 0013-lvm-dbus-Fix-memory-leak.patch | 24 +++++++++ 0014-mdraid-Fix-memory-leak.patch | 24 +++++++++ 0015-swap-Fix-memory-leak.patch | 24 +++++++++ libblockdev.spec | 14 ++++- 10 files changed, 302 insertions(+), 1 deletion(-) create mode 100644 0007-fs-Fix-return-values-in-bd_fs_ntfs_get_info.patch create mode 100644 0008-fs-Fix-return-values-in-bd_fs_xfs_get_info.patch create mode 100644 0009-dm-Fix-comparing-DM-RAID-member-devices-UUID.patch create mode 100644 0010-dm-Fix-memory-leak-in-the-DM-plugin-and-DM-logging-r.patch create mode 100644 0011-fs-Fix-memory-leak.patch create mode 100644 0012-kbd-Fix-memory-leak.patch create mode 100644 0013-lvm-dbus-Fix-memory-leak.patch create mode 100644 0014-mdraid-Fix-memory-leak.patch create mode 100644 0015-swap-Fix-memory-leak.patch diff --git a/0007-fs-Fix-return-values-in-bd_fs_ntfs_get_info.patch b/0007-fs-Fix-return-values-in-bd_fs_ntfs_get_info.patch new file mode 100644 index 0000000..0f7f8ea --- /dev/null +++ b/0007-fs-Fix-return-values-in-bd_fs_ntfs_get_info.patch @@ -0,0 +1,52 @@ +From 90b119f3026af68e2478450c7a71ed0fe68a9cbc Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Tue, 11 Aug 2020 18:00:57 +0200 +Subject: [PATCH 07/15] fs: Fix return values in bd_fs_ntfs_get_info + +--- + src/plugins/fs/ntfs.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/src/plugins/fs/ntfs.c b/src/plugins/fs/ntfs.c +index fdd959a..b406f41 100644 +--- a/src/plugins/fs/ntfs.c ++++ b/src/plugins/fs/ntfs.c +@@ -253,7 +253,7 @@ BDFSNtfsInfo* bd_fs_ntfs_get_info (const gchar *device, GError **error) { + g_autofree gchar* mountpoint = NULL; + + if (!check_deps (&avail_deps, DEPS_NTFSCLUSTER_MASK, deps, DEPS_LAST, &deps_check_lock, error)) +- return FALSE; ++ return NULL; + + mountpoint = bd_fs_get_mountpoint (device, error); + if (mountpoint != NULL) { +@@ -270,7 +270,7 @@ BDFSNtfsInfo* bd_fs_ntfs_get_info (const gchar *device, GError **error) { + success = bd_utils_exec_and_capture_output (args, NULL, &output, error); + if (!success) + /* error is already populated */ +- return FALSE; ++ return NULL; + + ret = g_new0 (BDFSNtfsInfo, 1); + lines = g_strsplit (output, "\n", 0); +@@ -283,7 +283,7 @@ BDFSNtfsInfo* bd_fs_ntfs_get_info (const gchar *device, GError **error) { + g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_PARSE, "Failed to parse NTFS file system information"); + g_strfreev (lines); + bd_fs_ntfs_info_free (ret); +- return FALSE; ++ return NULL; + } + + /* extract data from something like this: "bytes per volume : 998240256" */ +@@ -297,7 +297,7 @@ BDFSNtfsInfo* bd_fs_ntfs_get_info (const gchar *device, GError **error) { + g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_PARSE, "Failed to parse NTFS file system information"); + g_strfreev (lines); + bd_fs_ntfs_info_free (ret); +- return FALSE; ++ return NULL; + } + + /* extract data from something like this: "bytes of free space : 992759808" */ +-- +1.8.3.1 + diff --git a/0008-fs-Fix-return-values-in-bd_fs_xfs_get_info.patch b/0008-fs-Fix-return-values-in-bd_fs_xfs_get_info.patch new file mode 100644 index 0000000..165f074 --- /dev/null +++ b/0008-fs-Fix-return-values-in-bd_fs_xfs_get_info.patch @@ -0,0 +1,52 @@ +From 63f5df1992b15c1d6a442f2d392fa3b92ecf7b92 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Tue, 11 Aug 2020 18:04:58 +0200 +Subject: [PATCH 08/15] fs: Fix return values in bd_fs_xfs_get_info + +--- + src/plugins/fs/xfs.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/src/plugins/fs/xfs.c b/src/plugins/fs/xfs.c +index b8b4bbe..d28ce72 100644 +--- a/src/plugins/fs/xfs.c ++++ b/src/plugins/fs/xfs.c +@@ -274,7 +274,7 @@ BDFSXfsInfo* bd_fs_xfs_get_info (const gchar *device, GError **error) { + if (!success) { + /* error is already populated */ + bd_fs_xfs_info_free (ret); +- return FALSE; ++ return NULL; + } + + lines = g_strsplit (output, "\n", 0); +@@ -288,7 +288,7 @@ BDFSXfsInfo* bd_fs_xfs_get_info (const gchar *device, GError **error) { + g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_PARSE, "Failed to parse xfs file system information"); + g_strfreev (lines); + bd_fs_xfs_info_free (ret); +- return FALSE; ++ return NULL; + } + + /* extract data from something like this: "data = bsize=4096 blocks=262400, imaxpct=25" */ +@@ -305,7 +305,7 @@ BDFSXfsInfo* bd_fs_xfs_get_info (const gchar *device, GError **error) { + g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_PARSE, "Failed to parse xfs file system information"); + g_strfreev (lines); + bd_fs_xfs_info_free (ret); +- return FALSE; ++ return NULL; + } + while (isdigit (*val_start) || isspace(*val_start)) + val_start++; +@@ -318,7 +318,7 @@ BDFSXfsInfo* bd_fs_xfs_get_info (const gchar *device, GError **error) { + g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_PARSE, "Failed to parse xfs file system information"); + g_strfreev (lines); + bd_fs_xfs_info_free (ret); +- return FALSE; ++ return NULL; + } + g_strfreev (lines); + +-- +1.8.3.1 + diff --git a/0009-dm-Fix-comparing-DM-RAID-member-devices-UUID.patch b/0009-dm-Fix-comparing-DM-RAID-member-devices-UUID.patch new file mode 100644 index 0000000..6a2f7d7 --- /dev/null +++ b/0009-dm-Fix-comparing-DM-RAID-member-devices-UUID.patch @@ -0,0 +1,30 @@ +From 332c90019613797a2a634020f288a81a09b8b985 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Tue, 18 Aug 2020 09:44:29 +0200 +Subject: [PATCH 09/15] dm: Fix comparing DM RAID member devices UUID + +There is no "UUID" property in UDev we must use the "ID_FS_UUID" +one. +This comparison works only because most DM RAID members don't have +UUID so the check is skipped, but it fails for DDF RAID members +which have a special GUID/UUID in UDev database. +--- + src/plugins/dm.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/plugins/dm.c b/src/plugins/dm.c +index fb4e50b..93a47f4 100644 +--- a/src/plugins/dm.c ++++ b/src/plugins/dm.c +@@ -481,7 +481,7 @@ static gboolean raid_dev_matches_spec (struct raid_dev *raid_dev, const gchar *n + + context = udev_new (); + device = udev_device_new_from_subsystem_sysname (context, "block", dev_name); +- dev_uuid = udev_device_get_property_value (device, "UUID"); ++ dev_uuid = udev_device_get_property_value (device, "ID_FS_UUID"); + major_str = udev_device_get_property_value (device, "MAJOR"); + minor_str = udev_device_get_property_value (device, "MINOR"); + +-- +1.8.3.1 + diff --git a/0010-dm-Fix-memory-leak-in-the-DM-plugin-and-DM-logging-r.patch b/0010-dm-Fix-memory-leak-in-the-DM-plugin-and-DM-logging-r.patch new file mode 100644 index 0000000..562d85d --- /dev/null +++ b/0010-dm-Fix-memory-leak-in-the-DM-plugin-and-DM-logging-r.patch @@ -0,0 +1,30 @@ +From 6c0ae13b509975e67c65d690d388afccc78a0b63 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Fri, 25 Sep 2020 14:23:24 +0200 +Subject: [PATCH 10/15] dm: Fix memory leak in the DM plugin and DM logging + redirect function + +conflict: + 1. there is no dm_logging.c in v2.24 + +Signed-off-by: Vojtech Trefny +Signed-off-by: Zhiqiang Liu +--- + src/plugins/dm.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/plugins/dm.c b/src/plugins/dm.c +index 93a47f4..e8f0f4e 100644 +--- a/src/plugins/dm.c ++++ b/src/plugins/dm.c +@@ -246,6 +246,7 @@ gchar* bd_dm_name_from_node (const gchar *dm_node, GError **error) { + + if (!success) { + /* errror is already populated */ ++ g_free (ret); + return NULL; + } + +-- +1.8.3.1 + diff --git a/0011-fs-Fix-memory-leak.patch b/0011-fs-Fix-memory-leak.patch new file mode 100644 index 0000000..4ada543 --- /dev/null +++ b/0011-fs-Fix-memory-leak.patch @@ -0,0 +1,29 @@ +From 11e899c9f7256cd549e6a0a5ef607925b15cdb7a Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Fri, 25 Sep 2020 14:24:14 +0200 +Subject: [PATCH 11/15] fs: Fix memory leak + +Conflict: +1. due to context differences, we have adapted the patch. + +Signed-off-by: Vojtech Trefny +Signed-off-by: Zhiqiang Liu +--- + src/plugins/fs/mount.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/plugins/fs/mount.c b/src/plugins/fs/mount.c +index 43d64e8..98110aa 100644 +--- a/src/plugins/fs/mount.c ++++ b/src/plugins/fs/mount.c +@@ -541,6 +541,7 @@ static gboolean run_as_user (MountFunc func, MountArgs *args, uid_t run_as_uid, + "Unknoen error while reading error."); + g_io_channel_unref (channel); + close (pipefd[0]); ++ g_free(error_msg); + return FALSE; + } + +-- +1.8.3.1 + diff --git a/0012-kbd-Fix-memory-leak.patch b/0012-kbd-Fix-memory-leak.patch new file mode 100644 index 0000000..ae7f52b --- /dev/null +++ b/0012-kbd-Fix-memory-leak.patch @@ -0,0 +1,24 @@ +From bc7fddbe15f21eba45d55b3d9a9feaabf954a309 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Fri, 25 Sep 2020 14:26:24 +0200 +Subject: [PATCH 12/15] kbd: Fix memory leak + +--- + src/plugins/kbd.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/plugins/kbd.c b/src/plugins/kbd.c +index a2908ec..41593be 100644 +--- a/src/plugins/kbd.c ++++ b/src/plugins/kbd.c +@@ -1254,6 +1254,7 @@ static gboolean get_cache_size_used (const gchar *cache_dev_sys, guint64 *size, + g_io_channel_unref (file); + + if (!found) { ++ g_free (line); + g_set_error (error, BD_KBD_ERROR, BD_KBD_ERROR_BCACHE_INVAL, + "Failed to get cache usage data"); + return FALSE; +-- +1.8.3.1 + diff --git a/0013-lvm-dbus-Fix-memory-leak.patch b/0013-lvm-dbus-Fix-memory-leak.patch new file mode 100644 index 0000000..fff88be --- /dev/null +++ b/0013-lvm-dbus-Fix-memory-leak.patch @@ -0,0 +1,24 @@ +From 696dd84099cc2144b7c6b530933bed01b5fbaac4 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Fri, 25 Sep 2020 14:26:37 +0200 +Subject: [PATCH 13/15] lvm-dbus: Fix memory leak + +--- + src/plugins/lvm-dbus.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/plugins/lvm-dbus.c b/src/plugins/lvm-dbus.c +index b0efe7a..bf60141 100644 +--- a/src/plugins/lvm-dbus.c ++++ b/src/plugins/lvm-dbus.c +@@ -2978,6 +2978,7 @@ gboolean bd_lvm_cache_detach (const gchar *vg_name, const gchar *cached_lv, gboo + lv_id = g_strdup_printf ("%s/%s", vg_name, cached_lv); + call_lvm_obj_method_sync (lv_id, CACHED_LV_INTF, "DetachCachePool", params, NULL, extra, TRUE, error); + g_free (lv_id); ++ g_free (cache_pool_name); + return ((*error) == NULL); + } + +-- +1.8.3.1 + diff --git a/0014-mdraid-Fix-memory-leak.patch b/0014-mdraid-Fix-memory-leak.patch new file mode 100644 index 0000000..399fc30 --- /dev/null +++ b/0014-mdraid-Fix-memory-leak.patch @@ -0,0 +1,24 @@ +From d60f654d4547febf7c6ce5353a403ca0df60450c Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Fri, 25 Sep 2020 14:27:22 +0200 +Subject: [PATCH 14/15] mdraid: Fix memory leak + +--- + src/plugins/mdraid.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/plugins/mdraid.c b/src/plugins/mdraid.c +index 74af744..b97bc64 100644 +--- a/src/plugins/mdraid.c ++++ b/src/plugins/mdraid.c +@@ -1332,6 +1332,7 @@ gchar* bd_md_name_from_node (const gchar *node, GError **error) { + continue; + } + node_name = g_path_get_basename (dev_path); ++ g_free (dev_path); + if (g_strcmp0 (node_name, node) == 0) { + found = TRUE; + name = g_path_get_basename (*path_p); +-- +1.8.3.1 + diff --git a/0015-swap-Fix-memory-leak.patch b/0015-swap-Fix-memory-leak.patch new file mode 100644 index 0000000..099c7ec --- /dev/null +++ b/0015-swap-Fix-memory-leak.patch @@ -0,0 +1,24 @@ +From 58e7484228fcfbffc439a9d5131a221dd9e35d5f Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Fri, 25 Sep 2020 14:27:54 +0200 +Subject: [PATCH 15/15] swap: Fix memory leak + +--- + src/plugins/swap.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/plugins/swap.c b/src/plugins/swap.c +index 102780a..115f8fc 100644 +--- a/src/plugins/swap.c ++++ b/src/plugins/swap.c +@@ -417,6 +417,7 @@ gboolean bd_swap_swapstatus (const gchar *device, GError **error) { + if (!real_device) { + /* the device doesn't exist and thus is not an active swap */ + g_clear_error (error); ++ g_free (file_content); + return FALSE; + } + } +-- +1.8.3.1 + diff --git a/libblockdev.spec b/libblockdev.spec index 69de633..446d237 100644 --- a/libblockdev.spec +++ b/libblockdev.spec @@ -1,6 +1,6 @@ Name: libblockdev Version: 2.24 -Release: 3 +Release: 4 Summary: libblockdev is a C library supporting GObject introspection for manipulation of block devices License: LGPLv2+ URL: https://github.com/storaged-project/libblockdev @@ -12,6 +12,15 @@ Patch3: 0003-exec-Fix-setting-locale-for-util-calls.patch Patch4: 0004-lvm-Fix-checking-for-LVM-VDO-dependencies.patch Patch5: 0005-lvm-dbus-Fix-memory-leak-in-bd_lvm_cache_attach.patch Patch6: 0006-lvm-Fix-memory-leak-bd_lvm_cache_create_cached_lv.patch +Patch7: 0007-fs-Fix-return-values-in-bd_fs_ntfs_get_info.patch +Patch8: 0008-fs-Fix-return-values-in-bd_fs_xfs_get_info.patch +Patch9: 0009-dm-Fix-comparing-DM-RAID-member-devices-UUID.patch +Patch10: 0010-dm-Fix-memory-leak-in-the-DM-plugin-and-DM-logging-r.patch +Patch11: 0011-fs-Fix-memory-leak.patch +Patch12: 0012-kbd-Fix-memory-leak.patch +Patch13: 0013-lvm-dbus-Fix-memory-leak.patch +Patch14: 0014-mdraid-Fix-memory-leak.patch +Patch15: 0015-swap-Fix-memory-leak.patch BuildRequires: git glib2-devel libyaml-devel libbytesize-devel parted-devel libuuid-devel ndctl-devel device-mapper-devel BuildRequires: device-mapper-devel dmraid-devel systemd-devel nss-devel volume_key-devel >= 0.3.9-7 libblkid-devel libmount-devel @@ -174,6 +183,9 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm} %changelog +* Fri Oct 30 2020 Zhiqiang Liu - 2.24-4 +- backport upstream patches-epoch2 to fix serveral problems + * Tue Jul 28 2020 Ruijun Ge - 2.24-3 - backport upstream patches -- Gitee