git: 4a521544a683 - main - linux(4): Don't miss error from underlying in sendfile
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 17 Aug 2023 19:58:41 UTC
The branch main has been updated by dchagin:
URL: https://cgit.FreeBSD.org/src/commit/?id=4a521544a683bd2140dcf596ee571a0f10f52890
commit 4a521544a683bd2140dcf596ee571a0f10f52890
Author: Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2023-08-17 19:57:17 +0000
Commit: Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2023-08-17 19:57:17 +0000
linux(4): Don't miss error from underlying in sendfile
MFC after: 1 month
---
sys/compat/linux/linux_socket.c | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c
index f768392be546..8def4dfaa665 100644
--- a/sys/compat/linux/linux_socket.c
+++ b/sys/compat/linux/linux_socket.c
@@ -2594,7 +2594,6 @@ linux_sendfile(struct thread *td, struct linux_sendfile_args *arg)
off_t offset64;
l_off_t offset;
- int ret;
int error;
if (arg->offset != NULL) {
@@ -2604,10 +2603,10 @@ linux_sendfile(struct thread *td, struct linux_sendfile_args *arg)
offset64 = offset;
}
- ret = linux_sendfile_common(td, arg->out, arg->in,
+ error = linux_sendfile_common(td, arg->out, arg->in,
arg->offset != NULL ? &offset64 : NULL, arg->count);
- if (arg->offset != NULL) {
+ if (error == 0 && arg->offset != NULL) {
#if defined(__i386__) || defined(__arm__) || \
(defined(__amd64__) && defined(COMPAT_LINUX32))
if (offset64 > INT32_MAX)
@@ -2615,11 +2614,9 @@ linux_sendfile(struct thread *td, struct linux_sendfile_args *arg)
#endif
offset = (l_off_t)offset64;
error = copyout(&offset, arg->offset, sizeof(offset));
- if (error != 0)
- return (error);
}
- return (ret);
+ return (error);
}
#if defined(__i386__) || defined(__arm__) || \
@@ -2629,7 +2626,6 @@ int
linux_sendfile64(struct thread *td, struct linux_sendfile64_args *arg)
{
off_t offset;
- int ret;
int error;
if (arg->offset != NULL) {
@@ -2638,16 +2634,13 @@ linux_sendfile64(struct thread *td, struct linux_sendfile64_args *arg)
return (error);
}
- ret = linux_sendfile_common(td, arg->out, arg->in,
+ error = linux_sendfile_common(td, arg->out, arg->in,
arg->offset != NULL ? &offset : NULL, arg->count);
- if (arg->offset != NULL) {
+ if (error == 0 && arg->offset != NULL)
error = copyout(&offset, arg->offset, sizeof(offset));
- if (error != 0)
- return (error);
- }
- return (ret);
+ return (error);
}
/* Argument list sizes for linux_socketcall */