diff options
author | Mark Johnston <markj@FreeBSD.org> | 2024-01-04 13:33:58 +0000 |
---|---|---|
committer | Mark Johnston <markj@FreeBSD.org> | 2024-01-11 14:19:19 +0000 |
commit | b8233245b8d04816d13ea0c4441c0ded57323840 (patch) | |
tree | 4086ad80bb42f5ce3f6bb7a81ac1fb79e3d7d171 | |
parent | 095ea495b84e09cca5f9b16cb12972377ab17149 (diff) | |
download | src-b8233245b8d04816d13ea0c4441c0ded57323840.tar.gz src-b8233245b8d04816d13ea0c4441c0ded57323840.zip |
stats: Check for errors from copyout()
This is in preparation for annotating copyin() and related functions
with __result_use_check.
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D43179
(cherry picked from commit a0993376ec5f979272a62b140ec9f41bc02107b3)
-rw-r--r-- | sys/kern/subr_stats.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/sys/kern/subr_stats.c b/sys/kern/subr_stats.c index 0e7d2fad5f68..6a9dff2b9126 100644 --- a/sys/kern/subr_stats.c +++ b/sys/kern/subr_stats.c @@ -1108,13 +1108,19 @@ stats_v1_blob_clone(struct statsblobv1 **dst, size_t dstmaxsz, */ #ifdef _KERNEL if (flags & SB_CLONE_USRDSTNOFAULT) - copyout_nofault(src, *dst, + error = copyout_nofault(src, *dst, offsetof(struct statsblob, maxsz)); else if (flags & SB_CLONE_USRDST) - copyout(src, *dst, offsetof(struct statsblob, maxsz)); + error = copyout(src, *dst, + offsetof(struct statsblob, maxsz)); else #endif memcpy(*dst, src, offsetof(struct statsblob, maxsz)); +#ifdef _KERNEL + if (error != 0) + goto out; +#endif + if (dstmaxsz >= src->cursz) { postcurszlen = src->cursz - @@ -1126,14 +1132,18 @@ stats_v1_blob_clone(struct statsblobv1 **dst, size_t dstmaxsz, } #ifdef _KERNEL if (flags & SB_CLONE_USRDSTNOFAULT) - copyout_nofault(&(src->cursz), &((*dst)->cursz), + error = copyout_nofault(&(src->cursz), &((*dst)->cursz), postcurszlen); else if (flags & SB_CLONE_USRDST) - copyout(&(src->cursz), &((*dst)->cursz), postcurszlen); + error = copyout(&(src->cursz), &((*dst)->cursz), + postcurszlen); else #endif memcpy(&((*dst)->cursz), &(src->cursz), postcurszlen); } +#ifdef _KERNEL +out: +#endif return (error); } |