All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: Qian Cai <cai@redhat.com>
Cc: David Howells <dhowells@redhat.com>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] pipe: Fix memory leaks in create_pipe_files()
Date: Thu, 1 Oct 2020 02:35:52 +0100	[thread overview]
Message-ID: <20201001013552.GD3421308@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20201001005804.25641-1-cai@redhat.com>

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.

      reply	other threads:[~2020-10-01  1:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-01  0:58 [PATCH] pipe: Fix memory leaks in create_pipe_files() Qian Cai
2020-10-01  1:35 ` Al Viro [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201001013552.GD3421308@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=cai@redhat.com \
    --cc=dhowells@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.