From nobody Thu Jan 04 13:40:24 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 4T5SQJ4qrSz56Q8B; Thu, 4 Jan 2024 13:40:24 +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 4T5SQJ3WbXz420J; Thu, 4 Jan 2024 13:40:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704375624; 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=zBdpsk5Ml6AjQKAqCEkDRg8iHxXBsUQdNkS2rl7m0dk=; b=QUkeaADpCOLgq6DB5nPMuFc/0b3oXoXGiz3aaInTt7cJ89MAqHNOIWAuQ4KDeciE23YEHP FY91FoTdmiuC+5wKBaB12ypqYBMGw6iOxORgFNjdIblYGNlQK/Zllx9+j5NDNsojQO50au 7ceA4KGMmX5W049pg6OwhwauOsZWl8tlFTsVwkbq/8Y8DNrfkmDQQABaJ4Uu1fYXGleKfh W5Q+B4JeyWgBGb5T80TTaEzlfOUdI11fRSj51lS+L6HwVFj4F+tAeSTbquVK4+Owu3DE7Z 5Cxmv2btsxApIOFPNcsmmxBOSV/yWp09VLj4bt2rixkjNi+XBue7e3P96K44AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704375624; 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=zBdpsk5Ml6AjQKAqCEkDRg8iHxXBsUQdNkS2rl7m0dk=; b=vgEN5D95tQ0upz+xtThjuC/4S/IMcmpoYcW3aDPcmcizH0XSmKeNz8k7CUGeB0sMwNYWi8 YSXe/NhAPKH/sqj9+hqY/L+0CovbdOk3ceHNS5IbaigRRDx+Y/95WjtlnBnj5jBP+BQPOL 9d8NDosva0286NlF2HIKVohuHcEEGwttGULBbqW2I5dyx22a7bhXc1nR63ebm26OWM6LMi 22uYNBXOzRBFNvTGBDuA9xdEGSelT8Q+S2MDls3HNH9q7dzvxOGz6XUTprbItWoWygeboM E//uRMiZ36jg+7O5FaOLv5/HWDE6P2jfdT/K0EFvFqo4Akdy+lNh/nK9rdIXYg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704375624; a=rsa-sha256; cv=none; b=aAMtVnchssYpJ9/M3J6c331JNOXWNmdoDiXte1F5pz0X82P75iv2hPmWib9IgUXXAL838g +OQrkrwI4K2nSRBHoqcAuO9eex1HPo9UPs5EmKsClLVCGjvuoLlAht6cd+uuh/SWdURKXt ylCr3OWRt4/2L2VfvYH+WksSy4TjisXpDf9Q0S2s8ut/1jym+JNkh1ohqtjvCIMxmeHw/7 ELnj9VxSL2c4BUoil2Dyod4szlJWwbAo8F+fv6NamxbNG1WuHtK7uozpxAY+CKpmOla0/R iyCmvuzA0S8U86TR1C/jW/s3xWZdOtHr1EQvsA+zDnd9iOeBSoaCf41ckky/yQ== 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 4T5SQJ2cn2zFSY; Thu, 4 Jan 2024 13:40:24 +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 404DeORC042122; Thu, 4 Jan 2024 13:40:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 404DeOAf042119; Thu, 4 Jan 2024 13:40:24 GMT (envelope-from git) Date: Thu, 4 Jan 2024 13:40:24 GMT Message-Id: <202401041340.404DeOAf042119@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 243e3ab3d34a - main - 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/main X-Git-Reftype: branch X-Git-Commit: 243e3ab3d34ada9da4f202f8cab90da2d6c49e5e Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=243e3ab3d34ada9da4f202f8cab90da2d6c49e5e commit 243e3ab3d34ada9da4f202f8cab90da2d6c49e5e Author: Mark Johnston AuthorDate: 2024-01-04 13:34:49 +0000 Commit: Mark Johnston CommitDate: 2024-01-04 13:39:53 +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 --- 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 b3cbdda78338..e3d82214a8a8 100644 --- a/sys/dev/bnxt/if_bnxt.c +++ b/sys/dev/bnxt/if_bnxt.c @@ -2568,15 +2568,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: @@ -2601,22 +2599,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: @@ -2628,15 +2624,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: @@ -2648,15 +2642,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: @@ -2670,15 +2662,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: @@ -2689,15 +2680,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: @@ -2709,15 +2698,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: @@ -2734,18 +2721,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: @@ -2757,15 +2743,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: @@ -2779,15 +2763,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: @@ -2798,15 +2780,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: @@ -2819,15 +2799,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: @@ -2840,15 +2818,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; } }