diff options
author | Mark Johnston <markj@FreeBSD.org> | 2023-12-26 01:35:43 +0000 |
---|---|---|
committer | Mark Johnston <markj@FreeBSD.org> | 2023-12-26 02:04:00 +0000 |
commit | 711880597c6c4ac971eb2aba6a2dadb5933d38dd (patch) | |
tree | 2e570da6ba1e6f3682d2826cc37c2e55047fae6f | |
parent | 2a1d50fc12f6e604da834fbaea961d412aae6e85 (diff) | |
download | src-711880597c6c4ac971eb2aba6a2dadb5933d38dd.tar.gz src-711880597c6c4ac971eb2aba6a2dadb5933d38dd.zip |
ath: Handle errors from copyout() in ath_rate_fetch_node_stats()
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D43096
-rw-r--r-- | sys/dev/ath/ath_rate/sample/sample.c | 24 |
1 files 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 |