From d2a5f0812bb96b6011b0f1cd7e820a0f2f63a15c Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Mon, 27 Jul 2020 14:28:55 +0000 Subject: [PATCH] mpr(4), mps(4): Stop checking for failures from malloc(M_WAITOK). PR: 240545 Submitted by: Andrew Reiter Reviewed by: imp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D25766 --- sys/dev/mpr/mpr.c | 9 --------- sys/dev/mpr/mpr_sas.c | 15 --------------- sys/dev/mpr/mpr_user.c | 7 ------- sys/dev/mps/mps.c | 8 -------- sys/dev/mps/mps_sas.c | 15 --------------- sys/dev/mps/mps_user.c | 7 ------- 6 files changed, 61 deletions(-) diff --git a/sys/dev/mpr/mpr.c b/sys/dev/mpr/mpr.c index 863c9a59c27d..b202ea40db45 100644 --- a/sys/dev/mpr/mpr.c +++ b/sys/dev/mpr/mpr.c @@ -1529,10 +1529,6 @@ mpr_alloc_requests(struct mpr_softc *sc) */ sc->commands = malloc(sizeof(struct mpr_command) * sc->num_reqs, M_MPR, M_WAITOK | M_ZERO); - if (!sc->commands) { - mpr_dprint(sc, MPR_ERROR, "Cannot allocate command memory\n"); - return (ENOMEM); - } for (i = 1; i < sc->num_reqs; i++) { cm = &sc->commands[i]; cm->cm_req = sc->req_frames + i * sc->reqframesz; @@ -2684,11 +2680,6 @@ mpr_register_events(struct mpr_softc *sc, uint8_t *mask, int error = 0; eh = malloc(sizeof(struct mpr_event_handle), M_MPR, M_WAITOK|M_ZERO); - if (!eh) { - mpr_dprint(sc, MPR_EVENT|MPR_ERROR, - "Cannot allocate event memory\n"); - return (ENOMEM); - } eh->callback = cb; eh->data = data; TAILQ_INSERT_TAIL(&sc->event_list, eh, eh_list); diff --git a/sys/dev/mpr/mpr_sas.c b/sys/dev/mpr/mpr_sas.c index 64eed15ea5a6..0e31f0c4d21e 100644 --- a/sys/dev/mpr/mpr_sas.c +++ b/sys/dev/mpr/mpr_sas.c @@ -736,11 +736,6 @@ mpr_attach_sas(struct mpr_softc *sc) mpr_dprint(sc, MPR_INIT, "%s entered\n", __func__); sassc = malloc(sizeof(struct mprsas_softc), M_MPR, M_WAITOK|M_ZERO); - if (!sassc) { - mpr_dprint(sc, MPR_INIT|MPR_ERROR, - "Cannot allocate SAS subsystem memory\n"); - return (ENOMEM); - } /* * XXX MaxTargets could change during a reinit. Since we don't @@ -751,12 +746,6 @@ mpr_attach_sas(struct mpr_softc *sc) sassc->maxtargets = sc->facts->MaxTargets + sc->facts->MaxVolumes; sassc->targets = malloc(sizeof(struct mprsas_target) * sassc->maxtargets, M_MPR, M_WAITOK|M_ZERO); - if (!sassc->targets) { - mpr_dprint(sc, MPR_INIT|MPR_ERROR, - "Cannot allocate SAS target memory\n"); - free(sassc, M_MPR); - return (ENOMEM); - } sc->sassc = sassc; sassc->sc = sc; @@ -3556,8 +3545,4 @@ mprsas_realloc_targets(struct mpr_softc *sc, int maxtargets) sassc->targets = malloc(sizeof(struct mprsas_target) * maxtargets, M_MPR, M_WAITOK|M_ZERO); - if (!sassc->targets) { - panic("%s failed to alloc targets with error %d\n", - __func__, ENOMEM); - } } diff --git a/sys/dev/mpr/mpr_user.c b/sys/dev/mpr/mpr_user.c index 308b559c7172..751741bcc4f6 100644 --- a/sys/dev/mpr/mpr_user.c +++ b/sys/dev/mpr/mpr_user.c @@ -1528,13 +1528,6 @@ mpr_diag_register(struct mpr_softc *sc, mpr_fw_diag_register_t *diag_register, bzero(sc->fw_diag_buffer, buffer_size); ctx = malloc(sizeof(*ctx), M_MPR, M_WAITOK | M_ZERO); - if (ctx == NULL) { - device_printf(sc->mpr_dev, "%s: context malloc failed\n", - __func__); - *return_code = MPR_FW_DIAG_ERROR_NO_BUFFER; - status = MPR_DIAG_FAILURE; - goto bailout; - } ctx->addr = &sc->fw_diag_busaddr; ctx->buffer_dmat = sc->fw_diag_dmat; ctx->buffer_dmamap = sc->fw_diag_map; diff --git a/sys/dev/mps/mps.c b/sys/dev/mps/mps.c index 9802296f06f8..1adbf58c9e17 100644 --- a/sys/dev/mps/mps.c +++ b/sys/dev/mps/mps.c @@ -1520,10 +1520,6 @@ mps_alloc_requests(struct mps_softc *sc) */ sc->commands = malloc(sizeof(struct mps_command) * sc->num_reqs, M_MPT2, M_WAITOK | M_ZERO); - if(!sc->commands) { - mps_dprint(sc, MPS_ERROR, "Cannot allocate command memory\n"); - return (ENOMEM); - } for (i = 1; i < sc->num_reqs; i++) { cm = &sc->commands[i]; cm->cm_req = sc->req_frames + i * sc->reqframesz; @@ -2598,10 +2594,6 @@ mps_register_events(struct mps_softc *sc, u32 *mask, int error = 0; eh = malloc(sizeof(struct mps_event_handle), M_MPT2, M_WAITOK|M_ZERO); - if(!eh) { - mps_dprint(sc, MPS_ERROR, "Cannot allocate event memory\n"); - return (ENOMEM); - } eh->callback = cb; eh->data = data; TAILQ_INSERT_TAIL(&sc->event_list, eh, eh_list); diff --git a/sys/dev/mps/mps_sas.c b/sys/dev/mps/mps_sas.c index fd3f47c63697..74fced8abfab 100644 --- a/sys/dev/mps/mps_sas.c +++ b/sys/dev/mps/mps_sas.c @@ -722,11 +722,6 @@ mps_attach_sas(struct mps_softc *sc) mps_dprint(sc, MPS_INIT, "%s entered\n", __func__); sassc = malloc(sizeof(struct mpssas_softc), M_MPT2, M_WAITOK|M_ZERO); - if(!sassc) { - mps_dprint(sc, MPS_INIT|MPS_ERROR, - "Cannot allocate SAS controller memory\n"); - return (ENOMEM); - } /* * XXX MaxTargets could change during a reinit. Since we don't @@ -737,12 +732,6 @@ mps_attach_sas(struct mps_softc *sc) sassc->maxtargets = sc->facts->MaxTargets + sc->facts->MaxVolumes; sassc->targets = malloc(sizeof(struct mpssas_target) * sassc->maxtargets, M_MPT2, M_WAITOK|M_ZERO); - if(!sassc->targets) { - mps_dprint(sc, MPS_INIT|MPS_ERROR, - "Cannot allocate SAS target memory\n"); - free(sassc, M_MPT2); - return (ENOMEM); - } sc->sassc = sassc; sassc->sc = sc; @@ -3421,8 +3410,4 @@ mpssas_realloc_targets(struct mps_softc *sc, int maxtargets) sassc->targets = malloc(sizeof(struct mpssas_target) * maxtargets, M_MPT2, M_WAITOK|M_ZERO); - if (!sassc->targets) { - panic("%s failed to alloc targets with error %d\n", - __func__, ENOMEM); - } } diff --git a/sys/dev/mps/mps_user.c b/sys/dev/mps/mps_user.c index 0a2506070849..15ae463a1ad1 100644 --- a/sys/dev/mps/mps_user.c +++ b/sys/dev/mps/mps_user.c @@ -1436,13 +1436,6 @@ mps_diag_register(struct mps_softc *sc, mps_fw_diag_register_t *diag_register, bzero(sc->fw_diag_buffer, buffer_size); ctx = malloc(sizeof(*ctx), M_MPSUSER, M_WAITOK | M_ZERO); - if (ctx == NULL) { - device_printf(sc->mps_dev, "%s: context malloc failed\n", - __func__); - *return_code = MPS_FW_DIAG_ERROR_NO_BUFFER; - status = MPS_DIAG_FAILURE; - goto bailout; - } ctx->addr = &sc->fw_diag_busaddr; ctx->buffer_dmat = sc->fw_diag_dmat; ctx->buffer_dmamap = sc->fw_diag_map;