[PATCH 1/2] Avoid use after free

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Jes Sorensen <Jes.Sorensen@xxxxxxxxxx>

If picking just one spare disk from the container, jump out of the
loop once freeing the list. Otherwise we end up accessing the list
that we just freed.

Signed-off-by: Jes Sorensen <Jes.Sorensen@xxxxxxxxxx>
---
 util.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/util.c b/util.c
index 2cf617d..1bbd87f 100644
--- a/util.c
+++ b/util.c
@@ -1766,6 +1766,7 @@ struct mdinfo *container_choose_spares(struct supertype *st,
 			if (get_one) {
 				sysfs_free(*dp);
 				d->next = NULL;
+				goto out;
 			}
 		} else {
 			*dp = d->next;
@@ -1773,5 +1774,6 @@ struct mdinfo *container_choose_spares(struct supertype *st,
 			sysfs_free(d);
 		}
 	}
+out:
 	return disks;
 }
-- 
1.7.6.4

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


[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux