mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-06 17:18:32 +00:00
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
This commit is contained in:
parent
969fc09134
commit
a0993376ec
|
@ -1107,13 +1107,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 -
|
||||
|
@ -1125,14 +1131,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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue