[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200513054609.GS23230@ZenIV.linux.org.uk>
Date: Wed, 13 May 2020 06:46:09 +0100
From: Al Viro <viro@...iv.linux.org.uk>
To: Shuah Khan <skhan@...uxfoundation.org>
Cc: axboe@...nel.dk, zohar@...ux.vnet.ibm.com, mcgrof@...nel.org,
keescook@...omium.org, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 1/2] fs: avoid fdput() after failed fdget() in
ksys_sync_file_range()
On Tue, May 12, 2020 at 01:43:04PM -0600, Shuah Khan wrote:
> @@ -364,15 +364,15 @@ int sync_file_range(struct file *file, loff_t offset, loff_t nbytes,
> int ksys_sync_file_range(int fd, loff_t offset, loff_t nbytes,
> unsigned int flags)
> {
> - int ret;
> - struct fd f;
> + int ret = -EBADF;
> + struct fd f = fdget(fd);
>
> - ret = -EBADF;
> - f = fdget(fd);
> - if (f.file)
> - ret = sync_file_range(f.file, offset, nbytes, flags);
> + if (!f.file)
> + goto out;
>
> + ret = sync_file_range(f.file, offset, nbytes, flags);
> fdput(f);
> +out:
> return ret;
IDGI... What's the point of that goto out, when it leads straight to return?
Powered by blists - more mailing lists