[PATCH 2/2] Create() check malloc() return value

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

 



From: Jes Sorensen <Jes.Sorensen@xxxxxxxxxx>

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

diff --git a/Create.c b/Create.c
index 3e85785..5d1548b 100644
--- a/Create.c
+++ b/Create.c
@@ -790,6 +790,10 @@ int Create(struct supertype *st, char *mddev,
 	}
 
 	infos = malloc(sizeof(*infos) * total_slots);
+	if (!infos) {
+		fprintf(stderr, Name ": Unable to allocate memory\n");
+		goto abort;
+	}
 
 	for (pass=1; pass <=2 ; pass++) {
 		struct mddev_dev *moved_disk = NULL; /* the disk that was moved out of the insert point */
-- 
1.7.4.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