From nobody Thu Jan 18 15:56:25 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TG6mp11Gsz56M6P; Thu, 18 Jan 2024 15:56:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TG6mn73YHz4pq2; Thu, 18 Jan 2024 15:56:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705593386; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=l1sKBtLKmL+PBiNdAHWUSP9V+1roxewiJJoCLiXl+kU=; b=KzH0WX6PRCshFDWjQdk7wPXNCk2T2HZZXrIc6n8OvcKsXnLw3NKkz8IpIS0Up/iZowF/nM 46PUZ3+klTzqppZOTraIopkjIZ14SbOKM/VgcnlNTfb9Z4sZo8IWq9kXP/zKFKM7R1uURD jxcKdw4XVrWlOd4iIFtrcBNSqRfKc8JjesGadjoqpcE96pB/4vuw4o+dpHaLeuFqktxilU T4RNa88dtZHgRzXTJjRIJnH59D2VpZKLlmZwlT5wqvCXlElA7vSd0XRsVWhdFZcgVDU+LA 5fq6fX/C7a0QQDeHFFU1exHn4AFYc4JJ64BCptWwYXc3liHYFPEqoqucIkwEhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705593386; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=l1sKBtLKmL+PBiNdAHWUSP9V+1roxewiJJoCLiXl+kU=; b=BlKZsgmZpPzqytVWMkLa5JMKbb/zhO5RxLQs5AloUdH8rTod8F5Ro0tC8MsfYahZebCS4r s2nAbcAyD0d4bHp1hOLLkOU2L+oZk29/dQuwAFhkkzgo4H6V43oDJKJjBv1EVW0jmUugt5 ssGWMfRsrHT8oOvKisCuIZywupJYf2/56MHLyFxebPikhTm1V+ZJq7BnPqkXeFhCZ1VVYw HMtwX9l3qmBkyt+0LCXLF69skw0UlB4SgVMsJ2JWELrQs0PHCpFoa+HJfVHLdPRbSczkFA 3hA4E9gGqNkNyL0UNpDYM+SsMtNIxHzmdAd95DP0VnmIp3AxyCd54T0xugyzqw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705593386; a=rsa-sha256; cv=none; b=gYbyZRU3NUUHkl9XvNaYV0hJpnYGLjBoeORtJ1ULnSxRU09AK4gYC0QNzpgPBczQxBcyJG vQJrocWkC2hgKEkB6zNRzFsteuEUDdoZ3wo92ZPSXG5/OcBgqg0VRL+CwWSQzI159QTKXH 92P8f/dBU6bBDat3KbpBZmqS4d6uwtjNozPOFYo2L7YaD+/eb/Je3wvVtholwpVxfAoJoE nH100X5E4uMqtQT1IU89T8OS/Lbvq5U4TfMhdVHJKxhNuCP8O1sSAqh3gvEhZWSm5yNlPM Ne8C6m6yYK5v2Y402TjQoh82xRVjyVsAB7GuSEpRHuZV3dxBL6w12zeDNpQP6w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TG6mn5rczz1CMc; Thu, 18 Jan 2024 15:56:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 40IFuPfC027722; Thu, 18 Jan 2024 15:56:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40IFuPcA027719; Thu, 18 Jan 2024 15:56:25 GMT (envelope-from git) Date: Thu, 18 Jan 2024 15:56:25 GMT Message-Id: <202401181556.40IFuPcA027719@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: b3ed2b808658 - stable/14 - bnxt: Handle errors from copyout() in ioctl handlers List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: b3ed2b808658cbf7d687d6a1a949da54909d0776 Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=b3ed2b808658cbf7d687d6a1a949da54909d0776 commit b3ed2b808658cbf7d687d6a1a949da54909d0776 Author: Mark Johnston AuthorDate: 2024-01-04 13:34:49 +0000 Commit: Mark Johnston 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; } }