Date: Thu, 18 Jan 2024 15:56:25 GMT From: Mark Johnston <markj@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: b3ed2b808658 - stable/14 - bnxt: Handle errors from copyout() in ioctl handlers Message-ID: <202401181556.40IFuPcA027719@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=b3ed2b808658cbf7d687d6a1a949da54909d0776 commit b3ed2b808658cbf7d687d6a1a949da54909d0776 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2024-01-04 13:34:49 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2024-01-18 15:53:37 +0000 bnxt: Handle errors from copyout() in ioctl handlers This is in preparation for annotating copyin() and related functions with __result_use_check. MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D43178 (cherry picked from commit 243e3ab3d34ada9da4f202f8cab90da2d6c49e5e) --- sys/dev/bnxt/if_bnxt.c | 112 +++++++++++++++++++------------------------------ 1 file changed, 44 insertions(+), 68 deletions(-) diff --git a/sys/dev/bnxt/if_bnxt.c b/sys/dev/bnxt/if_bnxt.c index 25715756ce29..70d699d4b419 100644 --- a/sys/dev/bnxt/if_bnxt.c +++ b/sys/dev/bnxt/if_bnxt.c @@ -2569,15 +2569,13 @@ bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t data) &find->fw_ver); if (rc) { iod->hdr.rc = rc; - copyout(&iod->hdr.rc, &ioh->rc, + rc = copyout(&iod->hdr.rc, &ioh->rc, sizeof(ioh->rc)); - } - else { + } else { iod->hdr.rc = 0; - copyout(iod, ioh, iol); + rc = copyout(iod, ioh, iol); } - rc = 0; goto exit; } case BNXT_HWRM_NVM_READ: @@ -2602,22 +2600,20 @@ bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t data) rd->offset + offset, csize, &dma_data); if (rc) { iod->hdr.rc = rc; - copyout(&iod->hdr.rc, &ioh->rc, + rc = copyout(&iod->hdr.rc, &ioh->rc, sizeof(ioh->rc)); break; - } - else { - copyout(dma_data.idi_vaddr, + } else { + rc = copyout(dma_data.idi_vaddr, rd->data + offset, csize); - iod->hdr.rc = 0; + iod->hdr.rc = rc; } remain -= csize; } - if (iod->hdr.rc == 0) - copyout(iod, ioh, iol); + if (rc == 0) + rc = copyout(iod, ioh, iol); iflib_dma_free(&dma_data); - rc = 0; goto exit; } case BNXT_HWRM_FW_RESET: @@ -2629,15 +2625,13 @@ bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t data) &rst->selfreset); if (rc) { iod->hdr.rc = rc; - copyout(&iod->hdr.rc, &ioh->rc, + rc = copyout(&iod->hdr.rc, &ioh->rc, sizeof(ioh->rc)); - } - else { + } else { iod->hdr.rc = 0; - copyout(iod, ioh, iol); + rc = copyout(iod, ioh, iol); } - rc = 0; goto exit; } case BNXT_HWRM_FW_QSTATUS: @@ -2649,15 +2643,13 @@ bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t data) &qstat->selfreset); if (rc) { iod->hdr.rc = rc; - copyout(&iod->hdr.rc, &ioh->rc, + rc = copyout(&iod->hdr.rc, &ioh->rc, sizeof(ioh->rc)); - } - else { + } else { iod->hdr.rc = 0; - copyout(iod, ioh, iol); + rc = copyout(iod, ioh, iol); } - rc = 0; goto exit; } case BNXT_HWRM_NVM_WRITE: @@ -2671,15 +2663,14 @@ bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t data) &wr->item_length, &wr->index); if (rc) { iod->hdr.rc = rc; - copyout(&iod->hdr.rc, &ioh->rc, + rc = copyout(&iod->hdr.rc, &ioh->rc, sizeof(ioh->rc)); } else { iod->hdr.rc = 0; - copyout(iod, ioh, iol); + rc = copyout(iod, ioh, iol); } - rc = 0; goto exit; } case BNXT_HWRM_NVM_ERASE_DIR_ENTRY: @@ -2690,15 +2681,13 @@ bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t data) rc = bnxt_hwrm_nvm_erase_dir_entry(softc, erase->index); if (rc) { iod->hdr.rc = rc; - copyout(&iod->hdr.rc, &ioh->rc, + rc = copyout(&iod->hdr.rc, &ioh->rc, sizeof(ioh->rc)); - } - else { + } else { iod->hdr.rc = 0; - copyout(iod, ioh, iol); + rc = copyout(iod, ioh, iol); } - rc = 0; goto exit; } case BNXT_HWRM_NVM_GET_DIR_INFO: @@ -2710,15 +2699,13 @@ bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t data) &info->entry_length); if (rc) { iod->hdr.rc = rc; - copyout(&iod->hdr.rc, &ioh->rc, + rc = copyout(&iod->hdr.rc, &ioh->rc, sizeof(ioh->rc)); - } - else { + } else { iod->hdr.rc = 0; - copyout(iod, ioh, iol); + rc = copyout(iod, ioh, iol); } - rc = 0; goto exit; } case BNXT_HWRM_NVM_GET_DIR_ENTRIES: @@ -2735,18 +2722,17 @@ bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t data) &get->entry_length, &dma_data); if (rc) { iod->hdr.rc = rc; - copyout(&iod->hdr.rc, &ioh->rc, + rc = copyout(&iod->hdr.rc, &ioh->rc, sizeof(ioh->rc)); - } - else { - copyout(dma_data.idi_vaddr, get->data, + } else { + rc = copyout(dma_data.idi_vaddr, get->data, get->entry_length * get->entries); - iod->hdr.rc = 0; - copyout(iod, ioh, iol); + iod->hdr.rc = rc; + if (rc == 0) + rc = copyout(iod, ioh, iol); } iflib_dma_free(&dma_data); - rc = 0; goto exit; } case BNXT_HWRM_NVM_VERIFY_UPDATE: @@ -2758,15 +2744,13 @@ bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t data) vrfy->ordinal, vrfy->ext); if (rc) { iod->hdr.rc = rc; - copyout(&iod->hdr.rc, &ioh->rc, + rc = copyout(&iod->hdr.rc, &ioh->rc, sizeof(ioh->rc)); - } - else { + } else { iod->hdr.rc = 0; - copyout(iod, ioh, iol); + rc = copyout(iod, ioh, iol); } - rc = 0; goto exit; } case BNXT_HWRM_NVM_INSTALL_UPDATE: @@ -2780,15 +2764,13 @@ bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t data) &inst->reset_required); if (rc) { iod->hdr.rc = rc; - copyout(&iod->hdr.rc, &ioh->rc, + rc = copyout(&iod->hdr.rc, &ioh->rc, sizeof(ioh->rc)); - } - else { + } else { iod->hdr.rc = 0; - copyout(iod, ioh, iol); + rc = copyout(iod, ioh, iol); } - rc = 0; goto exit; } case BNXT_HWRM_NVM_MODIFY: @@ -2799,15 +2781,13 @@ bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t data) mod->offset, mod->data, true, mod->length); if (rc) { iod->hdr.rc = rc; - copyout(&iod->hdr.rc, &ioh->rc, + rc = copyout(&iod->hdr.rc, &ioh->rc, sizeof(ioh->rc)); - } - else { + } else { iod->hdr.rc = 0; - copyout(iod, ioh, iol); + rc = copyout(iod, ioh, iol); } - rc = 0; goto exit; } case BNXT_HWRM_FW_GET_TIME: @@ -2820,15 +2800,13 @@ bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t data) >m->second, >m->millisecond, >m->zone); if (rc) { iod->hdr.rc = rc; - copyout(&iod->hdr.rc, &ioh->rc, + rc = copyout(&iod->hdr.rc, &ioh->rc, sizeof(ioh->rc)); - } - else { + } else { iod->hdr.rc = 0; - copyout(iod, ioh, iol); + rc = copyout(iod, ioh, iol); } - rc = 0; goto exit; } case BNXT_HWRM_FW_SET_TIME: @@ -2841,15 +2819,13 @@ bnxt_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t data) stm->second, stm->millisecond, stm->zone); if (rc) { iod->hdr.rc = rc; - copyout(&iod->hdr.rc, &ioh->rc, + rc = copyout(&iod->hdr.rc, &ioh->rc, sizeof(ioh->rc)); - } - else { + } else { iod->hdr.rc = 0; - copyout(iod, ioh, iol); + rc = copyout(iod, ioh, iol); } - rc = 0; goto exit; } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202401181556.40IFuPcA027719>