[PATCH] FIX: Seg Fault in incremental if BBM log detected

[PATCH] FIX: Seg Fault in incremental if BBM log detected

am 16.02.2011 13:42:04 von krzysztof.wojcik

Bug detected for imsm metadata.
Assembling of array using Incremental switch generate segmentation
fault if BBM log is detected.
Reason: missing return from Incremental_container if BBM is detected
and unnecessary list=NULL assignment.
This patch fix the problem and memory leak in this area.

Signed-off-by: Krzysztof Wojcik
---
Incremental.c | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/Incremental.c b/Incremental.c
index 889184f..26739fe 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -1471,7 +1471,19 @@ static int Incremental_container(struct supertype *st, char *devname,
if (list->array.state & (1< fprintf(stderr, Name ": BBM log found in metadata. "
"Cannot activate array(s).\n");
- list = NULL;
+ /* free container data and exit */
+ while (list) {
+ struct mdinfo *d1 = list->next;
+ struct mdinfo *disk = list->devs;
+ while (disk) {
+ struct mdinfo *d2 = disk->next;
+ free(disk);
+ disk = d2;
+ }
+ free(list);
+ list = d1;
+ }
+ return 2;
}

for (ra = list ; ra ; ra = ra->next) {

--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: [PATCH] FIX: Seg Fault in incremental if BBM log detected

am 17.02.2011 07:07:06 von NeilBrown

On Wed, 16 Feb 2011 13:42:04 +0100 Krzysztof Wojcik
wrote:

> Bug detected for imsm metadata.
> Assembling of array using Incremental switch generate segmentation
> fault if BBM log is detected.
> Reason: missing return from Incremental_container if BBM is detected
> and unnecessary list=NULL assignment.
> This patch fix the problem and memory leak in this area.
>
> Signed-off-by: Krzysztof Wojcik
> ---
> Incremental.c | 14 +++++++++++++-
> 1 files changed, 13 insertions(+), 1 deletions(-)
>
> diff --git a/Incremental.c b/Incremental.c
> index 889184f..26739fe 100644
> --- a/Incremental.c
> +++ b/Incremental.c
> @@ -1471,7 +1471,19 @@ static int Incremental_container(struct supertype *st, char *devname,
> if (list->array.state & (1< > fprintf(stderr, Name ": BBM log found in metadata. "
> "Cannot activate array(s).\n");
> - list = NULL;
> + /* free container data and exit */
> + while (list) {
> + struct mdinfo *d1 = list->next;
> + struct mdinfo *disk = list->devs;
> + while (disk) {
> + struct mdinfo *d2 = disk->next;
> + free(disk);
> + disk = d2;
> + }
> + free(list);
> + list = d1;
> + }

That can all be replaced with
sysfs_free(list);

> + return 2;

With that change, I have applied this patch, thanks.

NeilBrown



> }
>
> for (ra = list ; ra ; ra = ra->next) {

--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html