lkml.org 
[lkml]   [2020]   [Sep]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] pipe: Fix memory leaks in create_pipe_files()
On Wed, Sep 30, 2020 at 08:58:04PM -0400, Qian Cai wrote:

> Fixes: c73be61cede5 ("pipe: Add general notification queue support")
> Signed-off-by: Qian Cai <cai@redhat.com>
> ---
> fs/pipe.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fs/pipe.c b/fs/pipe.c
> index 60dbee457143..5184972cd9c0 100644
> --- a/fs/pipe.c
> +++ b/fs/pipe.c
> @@ -920,10 +920,13 @@ int create_pipe_files(struct file **res, int flags)
> if (flags & O_NOTIFICATION_PIPE) {
> #ifdef CONFIG_WATCH_QUEUE
> if (watch_queue_init(inode->i_pipe) < 0) {
> + free_pipe_info(inode->i_pipe);
> iput(inode);
> return -ENOMEM;
> }
> #else
> + free_pipe_info(inode->i_pipe);
> + iput(inode);
> return -ENOPKG;
> #endif
> }

yeccchhhh... This is too ugly to live.

1) get rid of that sodding ifdef; define watch_queue_init() to fail if
CONFIG_WATCH_QUEUE is not defined.

2) do not ignore the return value.

\
 
 \ /
  Last update: 2020-10-01 03:37    [W:0.045 / U:0.380 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site