1 From bb1014e4e66c6a113f208d2ede8e484f7b702a9d Mon Sep 17 00:00:00 2001
2 From: Amarnath Valluri <amarnath.valluri@intel.com>
3 Date: Mon, 3 Aug 2015 11:46:33 +0300
4 Subject: [PATCH 16/18] libparted: Fix memory leaks
6 * libparted/fs/r/hfs/hfs.c(hfsplus_resize): Don't leak embedded_geom
7 when volume resizing failed.
8 * libparted/fs/fat/fat.c(fat_create): Don't leake fs in-case of
9 fat_write_clustor failuer.
10 * libparted/arch/linux.c(_kernel_get_partition_start_and_length): Don't leak
11 dev_fd file descriptor.
13 Signed-off-by: Amarnath Valluri <amarnath.valluri@intel.com>
14 Signed-off-by: Brian C. Lane <bcl@redhat.com>
15 (cherry picked from commit b70ecd7a7ef1f69b0afd5c239681decbf369f5d9)
17 libparted/arch/linux.c | 1 +
18 libparted/fs/r/fat/fat.c | 2 +-
19 libparted/fs/r/hfs/hfs.c | 1 +
20 3 files changed, 3 insertions(+), 1 deletion(-)
22 diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
23 index 1d4cf17..d33c02d 100644
24 --- a/libparted/arch/linux.c
25 +++ b/libparted/arch/linux.c
26 @@ -2655,6 +2655,7 @@ _kernel_get_partition_start_and_length(PedPartition const *part,
27 int dev_fd = open (dev_name, O_RDONLY);
28 if (dev_fd != -1 && ioctl (dev_fd, HDIO_GETGEO, &geom)) {
34 diff --git a/libparted/fs/r/fat/fat.c b/libparted/fs/r/fat/fat.c
35 index 5aa72d8..4ecf5c5 100644
36 --- a/libparted/fs/r/fat/fat.c
37 +++ b/libparted/fs/r/fat/fat.c
38 @@ -305,7 +305,7 @@ fat_create (PedGeometry* geom, FatType fat_type, PedTimer* timer)
39 memset (fs_info->buffer, 0, fs_info->cluster_size);
40 if (!fat_write_cluster (fs, fs_info->buffer,
41 fs_info->root_cluster))
43 + goto error_free_buffers;
46 fs_info->serial_number = generate_random_uint32 ();
47 diff --git a/libparted/fs/r/hfs/hfs.c b/libparted/fs/r/hfs/hfs.c
48 index a1c37cc..7109a45 100644
49 --- a/libparted/fs/r/hfs/hfs.c
50 +++ b/libparted/fs/r/hfs/hfs.c
51 @@ -985,6 +985,7 @@ hfsplus_resize (PedFileSystem* fs, PedGeometry* geom, PedTimer* timer)
52 /* Resize the HFS+ volume */
53 if (!hfsplus_volume_resize (fs, embedded_geom, timer_plus)) {
54 if (timer_plus != timer) ped_timer_destroy_nested (timer_plus);
55 + if (priv_data->wrapper) ped_geometry_destroy (embedded_geom);