* [PATCH] splice: fix possible memory leak in vmsplice_to_user().
@ 2014-05-01 3:22 Leon Yu
0 siblings, 0 replies; only message in thread
From: Leon Yu @ 2014-05-01 3:22 UTC (permalink / raw)
To: Alexander Viro; +Cc: linux-kernel, linux-fsdevel, Leon Yu
Since commit 6130f5315 ("switch vmsplice_to_user() to copy_page_to_iter()"),
rw_copy_check_uvector is used for sanity check, however, iov can be leaked if
that check failed.
So, fix it by handling this error path properly.
Signed-off-by: Leon Yu <chianglungyu@gmail.com>
---
fs/splice.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/splice.c b/fs/splice.c
index 9bc07d2..b789328 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -1546,7 +1546,7 @@ static long vmsplice_to_user(struct file *file, const struct iovec __user *uiov,
ret = rw_copy_check_uvector(READ, uiov, nr_segs,
ARRAY_SIZE(iovstack), iovstack, &iov);
if (ret <= 0)
- return ret;
+ goto out;
iov_iter_init(&iter, iov, nr_segs, count, 0);
@@ -1560,6 +1560,7 @@ static long vmsplice_to_user(struct file *file, const struct iovec __user *uiov,
ret = __splice_from_pipe(pipe, &sd, pipe_to_user);
pipe_unlock(pipe);
+out:
if (iov != iovstack)
kfree(iov);
--
1.9.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2014-05-01 3:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-01 3:22 [PATCH] splice: fix possible memory leak in vmsplice_to_user() Leon Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).