[PATCH 12/13] Handle malloc() failure in mdstat.c

[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>
---
 mdstat.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/mdstat.c b/mdstat.c
index abf6bf9..346a1e8 100644
--- a/mdstat.c
+++ b/mdstat.c
@@ -104,6 +104,11 @@ static int add_member_devname(struct dev_member **m, char *name)
 		return 0;
 
 	new = malloc(sizeof(*new));
+	if (!new) {
+		fprintf(stderr, Name ": %s unable to allocate memory\n",
+			__func__);
+		return 0;
+	}
 	new->name = strndup(name, t - name);
 	new->next = *m;
 	*m = new;
-- 
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