From nobody Tue Jan 02 00:37:22 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 4T3v7k6kpkz55yjN; Tue, 2 Jan 2024 00:37:22 +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 4T3v7k4xh4z3HgF; Tue, 2 Jan 2024 00:37:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704155842; 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=RyVjmXXm6DW1ppQnK6M1Bf7MCprNwZTW/TzIIBMxKN8=; b=pXV86w6/8SX73xiaR866CSJ6X/dIw5WSGF0+O3WBDgwz7patW67ruxp/dv4osa82WT0BOF HKoepBf8X6+ExMmHZlSKPvPI+nWzgwaY+DGcPKLibZ0CpCcWOG0m0LNV3J4bW3L8oDssd8 kw5wDJ70MjAtxBp+8uL4PPVuX+/Sm7GAdxcqC37JXyUYVE66br6RN4ycM6X4HywZOQ8/Le L1lZXQqRRh5d5JPn+k2KKTJkPsMrOEWtVf+sVDMQAc2PvTFmkI1XiSdjXqRPCefrnPiFMI UX6Xtq7t0Ni9KJoiM79Q4sLT5iccV/KrJ41P0vkQ57mt73r9CxwgEMM0r5+/BQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704155842; a=rsa-sha256; cv=none; b=kccM6zDRDnkavqsSk2DSyP6nh6IXY9cYr4RDwz+iUBKswgzulSiUo20wVR1JJk1+3QghhV ojtnqNarWXYjoG5i8rHzVUTMWDRJVfCtR9jcUBa3HAXA1+99Wne6qR9RoUNyLKW8RnynmQ ap5y8HdTPNr2b64IqDYRPKg66JwL4qF9APVVn+z4Qxy8IldKh6hsZhrg0axS1Mzf0Rt5xY uxh06J/eIKt8fMthRparEylc968dy+ePSVQ5QaoZtLnvRDOYGwpkMer4wgGBNRghh6hawY jdy49UkLyetPampH7dWrvc+qlHf2UdptzmV9mvwKO+UAscLdPnPFg12ho4cM7Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704155842; 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=RyVjmXXm6DW1ppQnK6M1Bf7MCprNwZTW/TzIIBMxKN8=; b=v26NybOKH3yAKIZZExxJBpGrA570Due0BvcJF8t6bAdg4fRD8FHOeRWpWH14Pg+Xcqn5Mm cKNHecB2Yv7YSRollgafTCC/ltgA+ybgfDSXFcjmgB+RP+mwIuOezXePJ6ImMNC0Yal7vj 7Zde3NHijjrg5EeJBWLmHQO8wy1ltpm45OTHIZek8U3xWQLG1ChNKyxODhIHsSUCcJdP6X yR2aBBaAnw6Sgud25q2piMO708OS2TAPLFMQs5YzY7oEGBNTSNk2O1lLV1UEnoHFtg6zlt 9sE9SeJTlfWdgEamfOcq1zJHI9oiauh6qyDxxE2BCzP2tszRPxVLirkEqZtcJQ== 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 4T3v7k43QMzflv; Tue, 2 Jan 2024 00:37:22 +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 4020bMFq085382; Tue, 2 Jan 2024 00:37:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 4020bMWY085379; Tue, 2 Jan 2024 00:37:22 GMT (envelope-from git) Date: Tue, 2 Jan 2024 00:37:22 GMT Message-Id: <202401020037.4020bMWY085379@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: cd4fa9258949 - stable/14 - ses: Add error checking for copyout() calls 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: cd4fa9258949b1a1a67a98022a350d4131faa6bd Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=cd4fa9258949b1a1a67a98022a350d4131faa6bd commit cd4fa9258949b1a1a67a98022a350d4131faa6bd Author: Mark Johnston AuthorDate: 2023-12-26 01:40:33 +0000 Commit: Mark Johnston CommitDate: 2024-01-02 00:29:50 +0000 ses: Add error checking for copyout() calls This is in preparation for annotating copyin() and related functions with __result_use_check. Reviewed by: mav, imp, asomers Tested by: asomers MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D43130 (cherry picked from commit 771501e96ffd7e314c338300a351ad76d28a2f69) --- sys/cam/scsi/scsi_enc_ses.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/sys/cam/scsi/scsi_enc_ses.c b/sys/cam/scsi/scsi_enc_ses.c index 767f4f0b7fa6..34e79b55ed51 100644 --- a/sys/cam/scsi/scsi_enc_ses.c +++ b/sys/cam/scsi/scsi_enc_ses.c @@ -2811,8 +2811,8 @@ ses_get_elm_desc(enc_softc_t *enc, encioc_elm_desc_t *elmd) } if (elmd->elm_desc_len > elmpriv->descr_len) elmd->elm_desc_len = elmpriv->descr_len; - copyout(elmpriv->descr, elmd->elm_desc_str, elmd->elm_desc_len); - return (0); + return (copyout(elmpriv->descr, elmd->elm_desc_str, + elmd->elm_desc_len)); } /** @@ -2828,7 +2828,7 @@ static int ses_get_elm_devnames(enc_softc_t *enc, encioc_elm_devnames_t *elmdn) { struct sbuf sb; - int len; + int error, len; len = elmdn->elm_names_size; if (len < 0) @@ -2840,10 +2840,13 @@ ses_get_elm_devnames(enc_softc_t *enc, encioc_elm_devnames_t *elmdn) ses_elmdevname_callback, &sb); sbuf_finish(&sb); elmdn->elm_names_len = sbuf_len(&sb); - copyout(sbuf_data(&sb), elmdn->elm_devnames, elmdn->elm_names_len + 1); + error = copyout(sbuf_data(&sb), elmdn->elm_devnames, + elmdn->elm_names_len + 1); sbuf_delete(&sb); cam_periph_lock(enc->periph); - return (elmdn->elm_names_len > 0 ? 0 : ENODEV); + if (error == 0 && elmdn->elm_names_len == 0) + error = ENODEV; + return (error); } /** @@ -2922,9 +2925,9 @@ ses_handle_string(enc_softc_t *enc, encioc_string_t *sstr, unsigned long ioc) size = rsize; if (size > sstr->bufsiz) size = sstr->bufsiz; - copyout(str, sstr->buf, size); + ret = copyout(str, sstr->buf, size); sstr->bufsiz = rsize; - return (size == rsize ? 0 : ENOMEM); + return (ret != 0 ? ret : (size == rsize ? 0 : ENOMEM)); case ENCIOC_GETENCID: if (ses_cache->ses_nsubencs < 1) return (ENODEV); @@ -2936,9 +2939,9 @@ ses_handle_string(enc_softc_t *enc, encioc_string_t *sstr, unsigned long ioc) size = rsize; if (size > sstr->bufsiz) size = sstr->bufsiz; - copyout(str, sstr->buf, size); + ret = copyout(str, sstr->buf, size); sstr->bufsiz = rsize; - return (size == rsize ? 0 : ENOMEM); + return (ret != 0 ? ret : (size == rsize ? 0 : ENOMEM)); default: return (EINVAL); }