git: 711880597c6c - main - ath: Handle errors from copyout() in ath_rate_fetch_node_stats()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 26 Dec 2023 02:04:11 UTC
The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=711880597c6c4ac971eb2aba6a2dadb5933d38dd commit 711880597c6c4ac971eb2aba6a2dadb5933d38dd Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2023-12-26 01:35:43 +0000 Commit: Mark Johnston <markj@FreeBSD.org> 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