On Fri, Jul 31, 2015 at 12:12:45PM +0300, Amarnath Valluri wrote:
> * libparted/fs/r/hfs/hfs.c(hfsplus_resize): Don't leak embedded_geom
>   when volume resizing failed.
> * libparted/fs/fat/fat.c(fat_create): Don't leake fs in-case of
>   fat_write_clustor failuer.
> * libparted/arch/linux.c(_kernel_get_partition_start_and_length): Don't leak
>   dev_fd file descriptor.
> 
> Signed-off-by: Amarnath Valluri <[email protected]>
> ---
>  libparted/arch/linux.c   | 1 +
>  libparted/fs/r/fat/fat.c | 2 +-
>  libparted/fs/r/hfs/hfs.c | 1 +
>  3 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
> index 27bbb80..349442b 100644
> --- a/libparted/arch/linux.c
> +++ b/libparted/arch/linux.c
> @@ -2665,6 +2665,7 @@ _kernel_get_partition_start_and_length(PedPartition 
> const *part,
>                  int dev_fd = open (dev_name, O_RDONLY);
>                  if (dev_fd != -1 && ioctl (dev_fd, HDIO_GETGEO, &geom)) {
>                          *start = geom.start;
> +                        close (dev_fd);
>                          ok = true;
>                  } else {
>                          if (dev_fd != -1)
> diff --git a/libparted/fs/r/fat/fat.c b/libparted/fs/r/fat/fat.c
> index 5aa72d8..4ecf5c5 100644
> --- a/libparted/fs/r/fat/fat.c
> +++ b/libparted/fs/r/fat/fat.c
> @@ -305,7 +305,7 @@ fat_create (PedGeometry* geom, FatType fat_type, 
> PedTimer* timer)
>               memset (fs_info->buffer, 0, fs_info->cluster_size);
>               if (!fat_write_cluster (fs, fs_info->buffer,
>                                       fs_info->root_cluster))
> -                     return 0;
> +                     goto error_free_buffers;
>       }

The ones above here look good to me.

>  
>       fs_info->serial_number = generate_random_uint32 ();
> diff --git a/libparted/fs/r/hfs/hfs.c b/libparted/fs/r/hfs/hfs.c
> index a1c37cc..61edcbb 100644
> --- a/libparted/fs/r/hfs/hfs.c
> +++ b/libparted/fs/r/hfs/hfs.c
> @@ -985,6 +985,7 @@ hfsplus_resize (PedFileSystem* fs, PedGeometry* geom, 
> PedTimer* timer)
>       /* Resize the HFS+ volume */
>       if (!hfsplus_volume_resize (fs, embedded_geom, timer_plus)) {
>               if (timer_plus != timer) ped_timer_destroy_nested (timer_plus);
> +             ped_geometry_destroy (embedded_geom);
>               ped_exception_throw (
>                       PED_EXCEPTION_ERROR,
>                       PED_EXCEPTION_CANCEL,

I think this needs to be wrapped in a priv_data->wrapper check,
otherwise it'll end up destroying the geom that's passed in from the
caller.

-- 
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)

Reply via email to