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