forked from pool/parted
- port fixes for various bugs from upstream (bsc#1136245) - add: libparted-dasd-correct-the-offset-where-the-first-pa.patch 4126d02, correct the offset where the first partition begins. This patch implements libparted-dasd-do-not-use-first-tracks.patch - remove: libparted-dasd-do-not-use-first-tracks.patch - add: parted-fix-crash-due-to-improper-partition-number-in.patch 149f009, fix crash due to improper partition number input, changed call to strtol, use base 0 to fit our parted-type.patch - modify: parted-type.patch (removed ui.c part) - add: parted-check-the-name-of-partition-first-when-to-nam.patch d7a2ff1, check the name of partition first when to name a partition - add: libparted-dasd-add-test-cases-for-the-new-fdasd-func.patch c11f5c0, 571e078, add test cases for the new fdasd functions - add: libparted-dasd-add-an-exception-for-changing-DASD-LD.patch ee2c0c2, add an exception for changing DASD-LDL partition table - add: libpartd-dasd-improve-flag-processing-for-DASD-LDL.patch 1545d6d, improve flag processing for DASD-LDL - add: clean-the-disk-information-when-commands-fail-in-int.patch 5a61f15, clean the disk information when commands fail in interactive mode - add: parted-ui-remove-unneccesary-information-of-command.patch 0b7946a, remove unneccesary information of command line - add: parted-fix-wrong-error-label-jump-in-mkpart.patch af150f6, fix wrong error label jump in mkpart - refresh: libparted-dasd-unify-vtoc-handling-for-cdl-ldl.patch 4f25d54, unify vtoc handling for cdl/ldl - refresh: libparted-dasd-update-and-improve-fdasd-functions.patch db37c8c, update and improve fdasd functions - refresh: libparted-dasd-add-new-fdasd-functions.patch b9e1281, add new fdasd functions OBS-URL: https://build.opensuse.org/request/show/712877 OBS-URL: https://build.opensuse.org/package/show/Base:System/parted?expand=0&rev=142
67 lines
2.7 KiB
Diff
67 lines
2.7 KiB
Diff
From af150f6764a08eae4b4cf448c392259c067a1523 Mon Sep 17 00:00:00 2001
|
|
From: Wang Dong <dongdwdw@linux.vnet.ibm.com>
|
|
Date: Fri, 23 Dec 2016 06:53:37 +0100
|
|
Subject: [PATCH] parted: fix wrong error label jump in mkpart
|
|
|
|
When the user makes a new partition, if parted fails to add the
|
|
partition to disk, it jumps to wrong error label. In this
|
|
situation, this new partition actually is not a node in disk
|
|
data structure. But in the wrong error label, it pretends this
|
|
is a node and removes it as a list node, leading to other
|
|
partition in this disk deleted. This might lead to a memory leak.
|
|
Because if there are other partitions, it just removes them from
|
|
list without releasing the resource. And this also leads to different
|
|
disk information between memory and device. This is confusing.
|
|
|
|
But when the new partition is added to disk successfully and if
|
|
any operations followed fail, this partition should be removed from
|
|
disk and destroyed.
|
|
|
|
Signed-off-by: Wang Dong <dongdwdw@linux.vnet.ibm.com>
|
|
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
|
|
---
|
|
parted/parted.c | 9 +++++----
|
|
1 file changed, 5 insertions(+), 4 deletions(-)
|
|
|
|
Index: parted-3.2/parted/parted.c
|
|
===================================================================
|
|
--- parted-3.2.orig/parted/parted.c
|
|
+++ parted-3.2/parted/parted.c
|
|
@@ -796,7 +796,7 @@ do_mkpart (PedDevice** dev, PedDisk** di
|
|
ped_constraint_destroy (constraint_any);
|
|
|
|
if (!added_ok)
|
|
- goto error_remove_part;
|
|
+ goto error_destroy_simple_constraints;
|
|
|
|
if (!ped_geometry_test_sector_inside(range_start, part->geom.start) ||
|
|
!ped_geometry_test_sector_inside(range_end, part->geom.end)) {
|
|
@@ -865,7 +865,7 @@ do_mkpart (PedDevice** dev, PedDisk** di
|
|
free (part_name); /* avoid double-free upon failure */
|
|
part_name = NULL;
|
|
if (!ped_partition_set_system (part, fs_type))
|
|
- goto error;
|
|
+ goto error_remove_part;
|
|
if (ped_partition_is_flag_available (part, PED_PARTITION_LBA))
|
|
ped_partition_set_flag (part, PED_PARTITION_LBA, 1);
|
|
if (ped_partition_is_flag_available (part, PED_PARTITION_SWAP) &&
|
|
@@ -881,7 +881,7 @@ do_mkpart (PedDevice** dev, PedDisk** di
|
|
}
|
|
|
|
if (!ped_disk_commit (disk))
|
|
- goto error;
|
|
+ goto error_remove_part;
|
|
|
|
/* clean up */
|
|
if (range_start != NULL)
|
|
@@ -904,7 +904,8 @@ error_remove_part:
|
|
error_destroy_simple_constraints:
|
|
ped_partition_destroy (part);
|
|
error:
|
|
- free (part_name);
|
|
+ if (part_name)
|
|
+ free (part_name);
|
|
if (range_start != NULL)
|
|
ped_geometry_destroy (range_start);
|
|
if (range_end != NULL)
|