From nobody Tue Dec 26 02:04:11 2023 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 4SzdP74hDtz55KRj; Tue, 26 Dec 2023 02:04:11 +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 4SzdP749fkz4Jql; Tue, 26 Dec 2023 02:04:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703556251; 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=Ekjyg+ipPy8ENRIt4CMKoAIhBycmcZ88HTVrU5UM0k8=; b=B604blLgtUoRcUXTrjN8w8X2K2bBfrxdM4IhmTZbfT91Dsv/6GAJhTIh4y18TAcNwB+woS pp2AUtcR2chyAnYY4W27v8a6wHSbr+HeYrSNrKeKJkJI+rVCOh3vekVpr/ihgtcIZhM/X0 iPSi+2auB3b6SGnh/UJalI2lFYG8U4h6Um/D/vfSS3pm/kYHpe86Osw4+7jviWpaI6Lzy9 LJNzYCEM7LUa5VQy25cV+m/a3kh4IEjtW9sQOxCP4FdZHPKg6OxM6JwXy/MaYXObp3bFog j6tHU8AcIllxKv7tIZcKlpN6Sbx/Snwx5PMAG/NbIVmeykfnb9xpaq+REYE2BQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1703556251; a=rsa-sha256; cv=none; b=a0An7LXiJI+KRrtmXsmtBW9x+afELJXg1wsjYHGtJ/Wwpv0hZNKVIxOTRk5WZKzcPwm579 m4k6u1C8Yeu0qOu3feeo4H23x9lCmEdlzFbisoGVPII7lsgHdBOfrMOLRM+3xrRGDPYlnH 4UGk+DYQ9gLQ+WTd0t+ETfLqoNsHLAjX0QZtWuHUlwXR56raMTciN0OOz11AnmmLjG0Spy JXfjh4AsGlkt2yrvgZhEfG4ltmNQfrfgFdVLh6oJl/xLUWA50h2k8mJnzIxuTg1AFWMaPA UDrSYQyfvk5Yl7ktuKWv3YAcuX0rjsEKDAcf1LC+207xhtmy6D8KkFQLT3v7UQ== 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=1703556251; 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=Ekjyg+ipPy8ENRIt4CMKoAIhBycmcZ88HTVrU5UM0k8=; b=ahMUsT5e7QuRaOdb0bNVdo9WcvhqQSnLcS933o4AtI5Gba5p3H35fdzsTBDnlryq+NQ/oZ JvrMYXapY+pJecJxoSloOkT8Hj7Dr6o6LRrC3ieBWjPDcrm/+wzBfiiB7OvhyE4+Kj7okf 9OKUhcQUam9E2D6nchb23N8sWqG2D0IQYBcca2/iXAwejpsx/TcfaLPsDdMKGj38Rvs+kX ymML5gJsvNh8bhrm6/u87mo6gS/ynEbTYGBQZqLDaxNjk9UI/2n5UGwk6KFYuwmzHDRXZJ 35ZQsSEIJIH4xLLKx3UxPi8LZ6G/NpMD8zPNwiB3jXyLpJhRfK2Gt3m3XeS+Yg== 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 4SzdP73DDHzbPq; Tue, 26 Dec 2023 02:04:11 +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 3BQ24Bup002629; Tue, 26 Dec 2023 02:04:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BQ24BEc002626; Tue, 26 Dec 2023 02:04:11 GMT (envelope-from git) Date: Tue, 26 Dec 2023 02:04:11 GMT Message-Id: <202312260204.3BQ24BEc002626@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: 711880597c6c - main - ath: Handle errors from copyout() in ath_rate_fetch_node_stats() 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: 711880597c6c4ac971eb2aba6a2dadb5933d38dd Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=711880597c6c4ac971eb2aba6a2dadb5933d38dd commit 711880597c6c4ac971eb2aba6a2dadb5933d38dd Author: Mark Johnston AuthorDate: 2023-12-26 01:35:43 +0000 Commit: Mark Johnston CommitDate: 2023-12-26 02:04:00 +0000 ath: Handle errors from copyout() in ath_rate_fetch_node_stats() MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D43096 --- sys/dev/ath/ath_rate/sample/sample.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/sys/dev/ath/ath_rate/sample/sample.c b/sys/dev/ath/ath_rate/sample/sample.c index 39ca5d1e9f31..8e70699f708d 100644 --- a/sys/dev/ath/ath_rate/sample/sample.c +++ b/sys/dev/ath/ath_rate/sample/sample.c @@ -1433,11 +1433,13 @@ ath_rate_fetch_node_stats(struct ath_softc *sc, struct ath_node *an, const HAL_RATE_TABLE *rt = sc->sc_currates; struct ath_rateioctl_tlv av; struct ath_rateioctl_rt *tv; - int y; + int error, y; int o = 0; ATH_NODE_LOCK_ASSERT(an); + error = 0; + /* * Ensure there's enough space for the statistics. */ @@ -1478,9 +1480,13 @@ ath_rate_fetch_node_stats(struct ath_softc *sc, struct ath_node *an, */ av.tlv_id = ATH_RATE_TLV_RATETABLE; av.tlv_len = sizeof(struct ath_rateioctl_rt); - copyout(&av, rs->buf + o, sizeof(struct ath_rateioctl_tlv)); + error = copyout(&av, rs->buf + o, sizeof(struct ath_rateioctl_tlv)); + if (error != 0) + goto out; o += sizeof(struct ath_rateioctl_tlv); - copyout(tv, rs->buf + o, sizeof(struct ath_rateioctl_rt)); + error = copyout(tv, rs->buf + o, sizeof(struct ath_rateioctl_rt)); + if (error != 0) + goto out; o += sizeof(struct ath_rateioctl_rt); /* @@ -1488,18 +1494,22 @@ ath_rate_fetch_node_stats(struct ath_softc *sc, struct ath_node *an, */ av.tlv_id = ATH_RATE_TLV_SAMPLENODE; av.tlv_len = sizeof(struct sample_node); - copyout(&av, rs->buf + o, sizeof(struct ath_rateioctl_tlv)); + error = copyout(&av, rs->buf + o, sizeof(struct ath_rateioctl_tlv)); + if (error != 0) + goto out; o += sizeof(struct ath_rateioctl_tlv); /* * Copy the statistics over to the provided buffer. */ - copyout(sn, rs->buf + o, sizeof(struct sample_node)); + error = copyout(sn, rs->buf + o, sizeof(struct sample_node)); + if (error != 0) + goto out; o += sizeof(struct sample_node); +out: free(tv, M_TEMP); - - return (0); + return (error); } static void