Blame SOURCES/0016-libparted-Fix-memory-leaks.patch

0cb0b9
From bb1014e4e66c6a113f208d2ede8e484f7b702a9d Mon Sep 17 00:00:00 2001
0cb0b9
From: Amarnath Valluri <amarnath.valluri@intel.com>
0cb0b9
Date: Mon, 3 Aug 2015 11:46:33 +0300
0cb0b9
Subject: [PATCH 16/18] libparted: Fix memory leaks
0cb0b9
0cb0b9
* libparted/fs/r/hfs/hfs.c(hfsplus_resize): Don't leak embedded_geom
0cb0b9
  when volume resizing failed.
0cb0b9
* libparted/fs/fat/fat.c(fat_create): Don't leake fs in-case of
0cb0b9
  fat_write_clustor failuer.
0cb0b9
* libparted/arch/linux.c(_kernel_get_partition_start_and_length): Don't leak
0cb0b9
  dev_fd file descriptor.
0cb0b9
0cb0b9
Signed-off-by: Amarnath Valluri <amarnath.valluri@intel.com>
0cb0b9
Signed-off-by: Brian C. Lane <bcl@redhat.com>
0cb0b9
(cherry picked from commit b70ecd7a7ef1f69b0afd5c239681decbf369f5d9)
0cb0b9
---
0cb0b9
 libparted/arch/linux.c   | 1 +
0cb0b9
 libparted/fs/r/fat/fat.c | 2 +-
0cb0b9
 libparted/fs/r/hfs/hfs.c | 1 +
0cb0b9
 3 files changed, 3 insertions(+), 1 deletion(-)
0cb0b9
0cb0b9
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
0cb0b9
index 1d4cf17..d33c02d 100644
0cb0b9
--- a/libparted/arch/linux.c
0cb0b9
+++ b/libparted/arch/linux.c
0cb0b9
@@ -2655,6 +2655,7 @@ _kernel_get_partition_start_and_length(PedPartition const *part,
0cb0b9
                 int dev_fd = open (dev_name, O_RDONLY);
0cb0b9
                 if (dev_fd != -1 && ioctl (dev_fd, HDIO_GETGEO, &geom)) {
0cb0b9
                         *start = geom.start;
0cb0b9
+                        close (dev_fd);
0cb0b9
                         ok = true;
0cb0b9
                 } else {
0cb0b9
                         if (dev_fd != -1)
0cb0b9
diff --git a/libparted/fs/r/fat/fat.c b/libparted/fs/r/fat/fat.c
0cb0b9
index 5aa72d8..4ecf5c5 100644
0cb0b9
--- a/libparted/fs/r/fat/fat.c
0cb0b9
+++ b/libparted/fs/r/fat/fat.c
0cb0b9
@@ -305,7 +305,7 @@ fat_create (PedGeometry* geom, FatType fat_type, PedTimer* timer)
0cb0b9
 		memset (fs_info->buffer, 0, fs_info->cluster_size);
0cb0b9
 		if (!fat_write_cluster (fs, fs_info->buffer,
0cb0b9
 					fs_info->root_cluster))
0cb0b9
-			return 0;
0cb0b9
+			goto error_free_buffers;
0cb0b9
 	}
0cb0b9
 
0cb0b9
 	fs_info->serial_number = generate_random_uint32 ();
0cb0b9
diff --git a/libparted/fs/r/hfs/hfs.c b/libparted/fs/r/hfs/hfs.c
0cb0b9
index a1c37cc..7109a45 100644
0cb0b9
--- a/libparted/fs/r/hfs/hfs.c
0cb0b9
+++ b/libparted/fs/r/hfs/hfs.c
0cb0b9
@@ -985,6 +985,7 @@ hfsplus_resize (PedFileSystem* fs, PedGeometry* geom, PedTimer* timer)
0cb0b9
 	/* Resize the HFS+ volume */
0cb0b9
 	if (!hfsplus_volume_resize (fs, embedded_geom, timer_plus)) {
0cb0b9
 		if (timer_plus != timer) ped_timer_destroy_nested (timer_plus);
0cb0b9
+		if (priv_data->wrapper) ped_geometry_destroy (embedded_geom);
0cb0b9
 		ped_exception_throw (
0cb0b9
 			PED_EXCEPTION_ERROR,
0cb0b9
 			PED_EXCEPTION_CANCEL,
0cb0b9
-- 
0cb0b9
2.4.3
0cb0b9