[PATCH 07/13] Fix malloc() failure handling in Monitor.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>
---
 Monitor.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/Monitor.c b/Monitor.c
index 101bca4..675ec00 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -177,6 +177,13 @@ int Monitor(struct mddev_dev *devlist,
 				st->devname = strdup(mdlist->devname);
 			else {
 				st->devname = malloc(8+strlen(mdlist->devname)+1);
+				/*
+				 * Treat malloc() failure the same as above
+				 */
+				if (!st->devname) {
+					free(st);
+					continue;
+				}
 				strcpy(strcpy(st->devname, "/dev/md/"),
 				       mdlist->devname);
 			}
-- 
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