diff --git a/sys/dev/ath/ath_rate/sample/sample.c b/sys/dev/ath/ath_rate/sample/sample.c --- a/sys/dev/ath/ath_rate/sample/sample.c +++ b/sys/dev/ath/ath_rate/sample/sample.c @@ -1433,11 +1433,13 @@ 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 @@ */ 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 @@ */ 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