udisks2: backport one patch to fix memory leak problems

backport one patch to fix memory leak problems

Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
This commit is contained in:
Zhiqiang Liu 2020-10-29 20:48:15 +08:00
parent e4acf76c6e
commit aecf38809f
2 changed files with 84 additions and 6 deletions

View File

@ -0,0 +1,79 @@
From 7c23020e3b6931395f85a08f6ab2b764a5625e43 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Tue, 29 Sep 2020 13:00:53 +0200
Subject: [PATCH 30/30] Memory leak fixes
Fixes for leaks found by new version of coverity.
---
modules/zram/udiskszramutil.c | 3 +++
src/udiskslinuxdriveata.c | 1 +
src/udiskslinuxfilesystem.c | 2 +-
tools/udisksctl.c | 2 ++
4 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/modules/zram/udiskszramutil.c b/modules/zram/udiskszramutil.c
index 96b2d66..2c64eb9 100644
--- a/modules/zram/udiskszramutil.c
+++ b/modules/zram/udiskszramutil.c
@@ -95,8 +95,11 @@ set_conf_property (char *filename,
if (rename (tmpfname, filename))
{
g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno),"%m");
+ g_free (tmpfname);
return FALSE;
}
+ g_free (tmpfname);
+
return TRUE;
}
diff --git a/src/udiskslinuxdriveata.c b/src/udiskslinuxdriveata.c
index 4ba66d0..f4e848c 100644
--- a/src/udiskslinuxdriveata.c
+++ b/src/udiskslinuxdriveata.c
@@ -582,6 +582,7 @@ udisks_linux_drive_ata_refresh_smart_sync (UDisksLinuxDriveAta *drive,
UDISKS_ERROR,
UDISKS_ERROR_FAILED,
"sk_disk_open: %m");
+ g_free (blob);
goto out;
}
diff --git a/src/udiskslinuxfilesystem.c b/src/udiskslinuxfilesystem.c
index 3ae11c3..279d952 100644
--- a/src/udiskslinuxfilesystem.c
+++ b/src/udiskslinuxfilesystem.c
@@ -697,9 +697,9 @@ calculate_mount_point (UDisksDaemon *daemon,
}
}
g_free (orig_mount_point);
- g_free (mount_dir);
out:
+ g_free (mount_dir);
g_clear_object (&object);
g_free (escaped_user_name);
return mount_point;
diff --git a/tools/udisksctl.c b/tools/udisksctl.c
index 3b0a48e..7a5de65 100644
--- a/tools/udisksctl.c
+++ b/tools/udisksctl.c
@@ -1282,6 +1282,7 @@ handle_command_unlock_lock (gint *argc,
g_printerr ("Error unlocking %s: %s\n",
udisks_block_get_device (block),
error->message);
+ g_clear_error (&error);
goto out;
}
g_variant_builder_add (&builder,
@@ -3103,6 +3104,7 @@ handle_command_status (gint *argc,
serial,
block);
g_free (block);
+ g_free (vendor_model);
}
--
1.8.3.1

View File

@ -18,7 +18,6 @@
%define default_luks_encryption luks1 %define default_luks_encryption luks1
%define is_fedora (0%{?rhel} == 0) && (0%{?openeuler} == 0) %define is_fedora (0%{?rhel} == 0) && (0%{?openeuler} == 0)
%define is_git %(git show > /dev/null 2>&1 && echo 1 || echo 0)
%define git_hash %(git log -1 --pretty=format:"%h" || true) %define git_hash %(git log -1 --pretty=format:"%h" || true)
%define build_date %(date '+%Y%m%d') %define build_date %(date '+%Y%m%d')
@ -59,17 +58,14 @@
Name: udisks2 Name: udisks2
Summary: Disk Manager Summary: Disk Manager
Version: 2.9.0 Version: 2.9.0
%if %{is_git} == 0 Release: 3
Release: 2
%else
Release: 0.%{build_date}git%{git_hash}%{?dist}
%endif
License: GPLv2+ License: GPLv2+
Group: System Environment/Libraries Group: System Environment/Libraries
URL: https://github.com/storaged-project/udisks URL: https://github.com/storaged-project/udisks
Source0: https://github.com/storaged-project/udisks/releases/download/udisks-%{version}/udisks-%{version}.tar.bz2 Source0: https://github.com/storaged-project/udisks/releases/download/udisks-%{version}/udisks-%{version}.tar.bz2
Patch1: 0001-udiskslinuxmountoptions-Prevent-a-memory-leak.patch Patch1: 0001-udiskslinuxmountoptions-Prevent-a-memory-leak.patch
Patch2: 0002-Memory-leak-fixes.patch
BuildRequires: glib2-devel >= %{glib2_version} BuildRequires: glib2-devel >= %{glib2_version}
BuildRequires: gobject-introspection-devel >= %{gobject_introspection_version} BuildRequires: gobject-introspection-devel >= %{gobject_introspection_version}
@ -441,6 +437,9 @@ udevadm trigger
%endif %endif
%changelog %changelog
* Thu Oct 29 2020 Zhiqiang Liu <lzhq28@mail.ustc.edu.cn> - 2.9.0-3
- backport one patch to fix memory leak problems
* Mon Jul 27 2020 Zhiqiang Liu <lzhq28@mail.ustc.edu.cn> - 2.9.0-2 * Mon Jul 27 2020 Zhiqiang Liu <lzhq28@mail.ustc.edu.cn> - 2.9.0-2
- update from 2.8.1 to 2.9.0 - update from 2.8.1 to 2.9.0