2018-05-02 18:22:07

by Ilya Dryomov

[permalink] [raw]
Subject: [PATCH 1/2] iov_iter: fix return type of __pipe_get_pages()

It returns -EFAULT and happens to be a helper for pipe_get_pages()
whose return type is ssize_t.

Signed-off-by: Ilya Dryomov <[email protected]>
---
lib/iov_iter.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 970212670b6a..4d5bf40d399d 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -1012,7 +1012,7 @@ unsigned long iov_iter_gap_alignment(const struct iov_iter *i)
}
EXPORT_SYMBOL(iov_iter_gap_alignment);

-static inline size_t __pipe_get_pages(struct iov_iter *i,
+static inline ssize_t __pipe_get_pages(struct iov_iter *i,
size_t maxsize,
struct page **pages,
int idx,
--
2.4.3



2018-05-02 18:22:43

by Ilya Dryomov

[permalink] [raw]
Subject: [PATCH 2/2] iov_iter: fix memory leak in pipe_get_pages_alloc()

Make n signed to avoid leaking the pages array if __pipe_get_pages()
fails.

Signed-off-by: Ilya Dryomov <[email protected]>
---
lib/iov_iter.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 4d5bf40d399d..fdae394172fa 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -1102,7 +1102,7 @@ static ssize_t pipe_get_pages_alloc(struct iov_iter *i,
size_t *start)
{
struct page **p;
- size_t n;
+ ssize_t n;
int idx;
int npages;

--
2.4.3


2018-05-02 18:41:15

by Al Viro

[permalink] [raw]
Subject: Re: [PATCH 2/2] iov_iter: fix memory leak in pipe_get_pages_alloc()

On Wed, May 02, 2018 at 08:16:57PM +0200, Ilya Dryomov wrote:
> Make n signed to avoid leaking the pages array if __pipe_get_pages()
> fails.

Applied, with s/fails/& to allocate any pages/.