Avoid double free creating a new RAID with invalid command line arguments.

Submitted by:	Xin Huang <xhuang sandvine com>
Reviewed by:	rstone@
MFC after:	1 week
This commit is contained in:
Ed Maste 2011-11-23 17:02:27 +00:00
parent 61f49b5bc9
commit f1e7af36c0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=227893

View File

@ -348,6 +348,7 @@ parse_array(int fd, int raid_type, char *array_str, struct array_info *info)
error = mfi_lookup_drive(fd, cp, &device_id);
if (error) {
free(info->drives);
info->drives = NULL;
return (error);
}
@ -355,12 +356,14 @@ parse_array(int fd, int raid_type, char *array_str, struct array_info *info)
error = errno;
warn("Failed to fetch drive info for drive %s", cp);
free(info->drives);
info->drives = NULL;
return (error);
}
if (pinfo->fw_state != MFI_PD_STATE_UNCONFIGURED_GOOD) {
warnx("Drive %u is not available", device_id);
free(info->drives);
info->drives = NULL;
return (EINVAL);
}
}