From: "J. Bruce Fields" <bfields@fieldses.org>
To: Chuck Ebbert <cebbert@redhat.com>
Cc: Pavel Emelyanov <xemul@openvz.org>,
Trond Myklebust <trond.myklebust@fys.uio.no>,
Andrew Morton <akpm@osdl.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
devel@openvz.org
Subject: Re: [PATCH] Memory shortage can result in inconsistent flocks state
Date: Thu, 13 Sep 2007 15:34:39 -0400 [thread overview]
Message-ID: <20070913193439.GA18052@fieldses.org> (raw)
In-Reply-To: <46E98F0C.10504@redhat.com>
On Thu, Sep 13, 2007 at 03:27:08PM -0400, Chuck Ebbert wrote:
> On 09/11/2007 08:38 AM, Pavel Emelyanov wrote:
> > diff --git a/fs/locks.c b/fs/locks.c
> > index 0db1a14..f59d066 100644
> > --- a/fs/locks.c
> > +++ b/fs/locks.c
> > @@ -732,6 +732,14 @@ static int flock_lock_file(struct file *
> > lock_kernel();
> > if (request->fl_flags & FL_ACCESS)
> > goto find_conflict;
> > +
> > + if (request->fl_type != F_UNLCK) {
> > + error = -ENOMEM;
> > + new_fl = locks_alloc_lock();
> > + if (new_fl == NULL)
> > + goto out;
> > + }
> > +
> > for_each_lock(inode, before) {
> > struct file_lock *fl = *before;
> > if (IS_POSIX(fl))
> > @@ -753,10 +761,6 @@ static int flock_lock_file(struct file *
> > goto out;
> > }
> >
> > - error = -ENOMEM;
> > - new_fl = locks_alloc_lock();
> > - if (new_fl == NULL)
> > - goto out;
> > /*
> > * If a higher-priority process was blocked on the old file lock,
> > * give it the opportunity to lock the file.
>
> Doesn't that create a leak in some cases?
>
> > for_each_lock(inode, before) {
> > struct file_lock *fl = *before;
> > if (IS_POSIX(fl))
> > break;
> > if (IS_LEASE(fl))
> > continue;
> > if (filp != fl->fl_file)
> > continue;
> > if (request->fl_type == fl->fl_type)
> > goto out; <<<<<<<<<<<<<<<< LEAK?
You mean, a leak of the memory allocated for new_fl? That's freed at
the exit labeled with "out". It's the only exit:
out:
unlock_kernel();
if (new_fl)
locks_free_lock(new_fl);
return error;
And new_fl is initially NULL, assigned only once by the allocation, then
assigned to NULL only at the very end when we know we've succeeded.
Am I missing something else?
--b.
> > found = 1;
> > locks_delete_lock(before);
> > break;
> > }
next prev parent reply other threads:[~2007-09-13 19:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-11 12:38 [PATCH] Memory shortage can result in inconsistent flocks state Pavel Emelyanov
2007-09-12 19:06 ` J. Bruce Fields
2007-09-13 6:04 ` Pavel Emelyanov
2007-09-13 7:16 ` Balbir Singh
2007-09-13 19:27 ` Chuck Ebbert
2007-09-13 19:34 ` J. Bruce Fields [this message]
2007-09-13 19:45 ` Chuck Ebbert
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=20070913193439.GA18052@fieldses.org \
--to=bfields@fieldses.org \
--cc=akpm@osdl.org \
--cc=cebbert@redhat.com \
--cc=devel@openvz.org \
--cc=linux-kernel@vger.kernel.org \
--cc=trond.myklebust@fys.uio.no \
--cc=xemul@openvz.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox