Skip to contentSkip to conversation

avoid double-free upon "old buggy kernel" sysfs_read failure

PATCH Applied Jim Meyering 2 participants 3 messages Feb 21, 2012 MD RAID

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 avoid double-free upon "old buggy kernel" sysfs_read failure

* Incremental.c (Incremental): On sysfs_read failure, don't call sysfs_free(sra) just before "goto out_unlock", since that very same "sra" is freed the same way by the clean-up code below.
---
FYI, coverity spotted the double free.

 Incremental.c |    1 -
 1 file changed, 1 deletion(-)
Incremental.c +0 -1
index 78c9712..4ab9747 100644
@@ -326,7 +326,6 @@ int Incremental(char *devname, int verbose, int runstop,
 			fprintf(stderr, Name
 		      ": You have an old buggy kernel which cannot support\n"
 				"      --incremental reliably.  Aborting.\n");
-			sysfs_free(sra);
 			rv = 2;
 			goto out_unlock;
 		}

--
1.7.9.1.266.g24ee9

#1 lore raw
Quoted 3 lines · Jim Meyering

* Incremental.c (Incremental): On sysfs_read failure, don't call sysfs_free(sra) just before "goto out_unlock", since that very same "sra" is freed the same way by the clean-up code below.

Here it is again, but with the Signed-off-by line:

From 981af2b292448a9daa56af86b4c514ad9339665a Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email protected]>
Date: Tue, 21 Feb 2012 11:08:25 +0100
Subject: [PATCH] avoid double-free upon "old buggy kernel" sysfs_read failure

* Incremental.c (Incremental): On sysfs_read failure, don't call sysfs_free(sra) just before "goto out_unlock", since that very same "sra" is freed the same way by the clean-up code below.

---
 Incremental.c |    1 -
 1 file changed, 1 deletion(-)
Incremental.c +0 -1
index b457bf3..836a6f1 100644
@@ -325,7 +325,6 @@ int Incremental(char *devname, int verbose, int runstop,
 			fprintf(stderr, Name
 		      ": You have an old buggy kernel which cannot support\n"
 				"      --incremental reliably.  Aborting.\n");
-			sysfs_free(sra);
 			rv = 2;
 			goto out_unlock;
 		}

--
1.7.9.1.266.g24ee9

Applied
#2 lore raw
Quoted 34 lines · On Tue, 21 Feb 2012 14:02:22 +0100 Jim Meyering <[email protected]> wrote:
Quoted 3 lines · Jim Meyering

* Incremental.c (Incremental): On sysfs_read failure, don't call sysfs_free(sra) just before "goto out_unlock", since that very same "sra" is freed the same way by the clean-up code below.

Here it is again, but with the Signed-off-by line:

Quoted 1 line

From 981af2b292448a9daa56af86b4c514ad9339665a Mon Sep 17 00:00:00 2001

From: Jim Meyering <[email protected]>
Date: Tue, 21 Feb 2012 11:08:25 +0100
Subject: [PATCH] avoid double-free upon "old buggy kernel" sysfs_read failure

* Incremental.c (Incremental): On sysfs_read failure, don't call sysfs_free(sra) just before "goto out_unlock", since that very same "sra" is freed the same way by the clean-up code below.

---
 Incremental.c |    1 -
 1 file changed, 1 deletion(-)
Incremental.c +0 -2
index b457bf3..836a6f1 100644
@@ -325,7 +325,6 @@ int Incremental(char *devname, int verbose, int runstop,
 			fprintf(stderr, Name
 		      ": You have an old buggy kernel which cannot support\n"
 				"      --incremental reliably.  Aborting.\n");
-			sysfs_free(sra);
 			rv = 2;
 			goto out_unlock;
 		}
--
Quoted 2 lines

1.7.9.1.266.g24ee9
--

Applied, thanks.

NeilBrown