Remove NULL checks after M_WAITOK allocations from mps(4).
Reviewed by: asomers@ MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D6296
This commit is contained in:
parent
d4d35ffaf8
commit
d05434d7bf
@ -699,11 +699,6 @@ mps_user_command(struct mps_softc *sc, struct mps_usr_command *cmd)
|
||||
|
||||
if (cmd->len > 0) {
|
||||
buf = malloc(cmd->len, M_MPSUSER, M_WAITOK|M_ZERO);
|
||||
if(!buf) {
|
||||
mps_printf(sc, "Cannot allocate memory %s %d\n",
|
||||
__func__, __LINE__);
|
||||
return (ENOMEM);
|
||||
}
|
||||
cm->cm_data = buf;
|
||||
cm->cm_length = cmd->len;
|
||||
} else {
|
||||
@ -930,25 +925,20 @@ mps_user_pass_thru(struct mps_softc *sc, mps_pass_thru_t *data)
|
||||
if (cm->cm_length != 0) {
|
||||
cm->cm_data = malloc(cm->cm_length, M_MPSUSER, M_WAITOK |
|
||||
M_ZERO);
|
||||
if (cm->cm_data == NULL) {
|
||||
mps_dprint(sc, MPS_FAULT, "%s: alloc failed for IOCTL "
|
||||
"passthru length %d\n", __func__, cm->cm_length);
|
||||
} else {
|
||||
cm->cm_flags = MPS_CM_FLAGS_DATAIN;
|
||||
if (data->DataOutSize) {
|
||||
cm->cm_flags |= MPS_CM_FLAGS_DATAOUT;
|
||||
err = copyin(PTRIN(data->PtrDataOut),
|
||||
cm->cm_data, data->DataOutSize);
|
||||
} else if (data->DataDirection ==
|
||||
MPS_PASS_THRU_DIRECTION_WRITE) {
|
||||
cm->cm_flags = MPS_CM_FLAGS_DATAOUT;
|
||||
err = copyin(PTRIN(data->PtrData),
|
||||
cm->cm_data, data->DataSize);
|
||||
}
|
||||
if (err != 0)
|
||||
mps_dprint(sc, MPS_FAULT, "%s: failed to copy "
|
||||
"IOCTL data from user space\n", __func__);
|
||||
cm->cm_flags = MPS_CM_FLAGS_DATAIN;
|
||||
if (data->DataOutSize) {
|
||||
cm->cm_flags |= MPS_CM_FLAGS_DATAOUT;
|
||||
err = copyin(PTRIN(data->PtrDataOut),
|
||||
cm->cm_data, data->DataOutSize);
|
||||
} else if (data->DataDirection ==
|
||||
MPS_PASS_THRU_DIRECTION_WRITE) {
|
||||
cm->cm_flags = MPS_CM_FLAGS_DATAOUT;
|
||||
err = copyin(PTRIN(data->PtrData),
|
||||
cm->cm_data, data->DataSize);
|
||||
}
|
||||
if (err != 0)
|
||||
mps_dprint(sc, MPS_FAULT, "%s: failed to copy "
|
||||
"IOCTL data from user space\n", __func__);
|
||||
}
|
||||
cm->cm_flags |= MPS_CM_FLAGS_SGE_SIMPLE;
|
||||
cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE;
|
||||
@ -2090,11 +2080,6 @@ mps_ioctl(struct cdev *dev, u_long cmd, void *arg, int flag,
|
||||
break;
|
||||
case MPSIO_READ_CFG_PAGE:
|
||||
mps_page = malloc(page_req->len, M_MPSUSER, M_WAITOK | M_ZERO);
|
||||
if(!mps_page) {
|
||||
mps_printf(sc, "Cannot allocate memory %s %d\n",
|
||||
__func__, __LINE__);
|
||||
return (ENOMEM);
|
||||
}
|
||||
error = copyin(page_req->buf, mps_page,
|
||||
sizeof(MPI2_CONFIG_PAGE_HEADER));
|
||||
if (error)
|
||||
@ -2113,11 +2098,6 @@ mps_ioctl(struct cdev *dev, u_long cmd, void *arg, int flag,
|
||||
break;
|
||||
case MPSIO_READ_EXT_CFG_PAGE:
|
||||
mps_page = malloc(ext_page_req->len, M_MPSUSER, M_WAITOK|M_ZERO);
|
||||
if(!mps_page) {
|
||||
mps_printf(sc, "Cannot allocate memory %s %d\n",
|
||||
__func__, __LINE__);
|
||||
return (ENOMEM);
|
||||
}
|
||||
error = copyin(ext_page_req->buf, mps_page,
|
||||
sizeof(MPI2_CONFIG_EXTENDED_PAGE_HEADER));
|
||||
if (error)
|
||||
@ -2131,11 +2111,6 @@ mps_ioctl(struct cdev *dev, u_long cmd, void *arg, int flag,
|
||||
break;
|
||||
case MPSIO_WRITE_CFG_PAGE:
|
||||
mps_page = malloc(page_req->len, M_MPSUSER, M_WAITOK|M_ZERO);
|
||||
if(!mps_page) {
|
||||
mps_printf(sc, "Cannot allocate memory %s %d\n",
|
||||
__func__, __LINE__);
|
||||
return (ENOMEM);
|
||||
}
|
||||
error = copyin(page_req->buf, mps_page, page_req->len);
|
||||
if (error)
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user