From: Jes Sorensen <Jes.Sorensen@xxxxxxxxxx> Signed-off-by: Jes Sorensen <Jes.Sorensen@xxxxxxxxxx> --- Manage.c | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Manage.c b/Manage.c index 2d8c916..024318b 100644 --- a/Manage.c +++ b/Manage.c @@ -143,6 +143,11 @@ static void remove_devices(int devnum, char *path) be = base + strlen(base); path2 = malloc(strlen(path)+20); + if (!path2) { + fprintf(stderr, Name ": %s unable to allocate memory\n", + __func__); + exit(1); + } strcpy(path2, path); pe = path2 + strlen(path2); @@ -898,8 +903,12 @@ int Manage_subdevs(char *devname, int fd, * As we are "--re-add"ing we must find a spare slot * to fill. */ - char *used = malloc(array.raid_disks); - memset(used, 0, array.raid_disks); + char *used = calloc(array.raid_disks, 1); + if (!used) { + fprintf(stderr, Name ": %s unable to " + "allocate memory\n", __func__); + return -ENOMEM; + } for (j=0; j< tst->max_devs; j++) { mdu_disk_info_t disc2; disc2.number = j; -- 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