From: Michael Halcrow <mhalcrow@us.ibm.com>
To: Andrea Righi <righiandr@users.sourceforge.net>
Cc: Andrew Morton <akpm@linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>,
Rusty Russell <prussell@au1.ibm.com>,
"David J. Kleikamp" <shaggy@us.ibm.com>,
"SERGE E. HALLYN" <sergeh@us.ibm.com>
Subject: [PATCH] eCryptfs: Remove useless lock
Date: Wed, 21 May 2008 10:39:15 -0500 [thread overview]
Message-ID: <20080521153915.GA942@halcrowt61p.austin.ibm.com> (raw)
In-Reply-To: <20080521151430.GG32643@halcrowt61p.austin.ibm.com>
On Wed, May 21, 2008 at 10:14:30AM -0500, Michael Halcrow wrote:
> On Wed, May 21, 2008 at 01:16:15AM +0200, Andrea Righi wrote:
> > Michael Halcrow wrote:
> >> + req = kmem_cache_alloc(ecryptfs_open_req_cache, GFP_KERNEL);
> >> + if (!req) {
> >> + rc = -ENOMEM;
> >> + goto out;
> >> + }
> >> + mutex_init(&req->mux);
> >> + req->lower_file = lower_file;
> >> + req->lower_dentry = lower_dentry;
> >> + req->lower_mnt = lower_mnt;
> >> + req->requesting_task = current;
> >> + req->flags = 0;
> >> + mutex_lock(&ecryptfs_kthread_ctl.mux);
> >> + mutex_lock(&req->mux);
> >> + if (ecryptfs_kthread_ctl.flags & ECRYPTFS_KTHREAD_ZOMBIE) {
> >> + rc = -EIO;
> >
> > Isn't a mutex_unlock(&req->mux) missing here?
>
> Nobody else actually has a reference to req at this point, so the
> unlock is not really necessary. It might not be a bad idea to jump to
> out_unlock anyway just to avoid future bugs.
>
> >> + mutex_unlock(&ecryptfs_kthread_ctl.mux);
> >> + printk(KERN_ERR "%s: We are in the middle of shutting down; "
> >> + "aborting privileged request to open lower file\n",
> >> + __func__);
> >> + goto out_free;
> >> + }
> >> + list_add_tail(&req->kthread_ctl_list, &ecryptfs_kthread_ctl.req_list);
> >> + mutex_unlock(&req->mux);
> >> + mutex_unlock(&ecryptfs_kthread_ctl.mux);
Nobody can get a reference to req so long as &ecryptfs_kthread_ctl.mux
is held. Remove lock of req->mux for newly created req.
Signed-off-by: Michael Halcrow <mhalcrow@us.ibm.com>
---
fs/ecryptfs/kthread.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/fs/ecryptfs/kthread.c b/fs/ecryptfs/kthread.c
index dba7c67..3d34327 100644
--- a/fs/ecryptfs/kthread.c
+++ b/fs/ecryptfs/kthread.c
@@ -158,7 +158,6 @@ int ecryptfs_privileged_open(struct file **lower_file,
req->requesting_task = current;
req->flags = 0;
mutex_lock(&ecryptfs_kthread_ctl.mux);
- mutex_lock(&req->mux);
if (ecryptfs_kthread_ctl.flags & ECRYPTFS_KTHREAD_ZOMBIE) {
rc = -EIO;
mutex_unlock(&ecryptfs_kthread_ctl.mux);
@@ -168,7 +167,6 @@ int ecryptfs_privileged_open(struct file **lower_file,
goto out_free;
}
list_add_tail(&req->kthread_ctl_list, &ecryptfs_kthread_ctl.req_list);
- mutex_unlock(&req->mux);
mutex_unlock(&ecryptfs_kthread_ctl.mux);
wake_up(&ecryptfs_kthread_ctl.wait);
schedule:
--
1.5.3.6
next prev parent reply other threads:[~2008-05-21 15:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-20 21:46 [PATCH] eCryptfs: Privileged kthread for lower file opens Michael Halcrow
2008-05-20 23:16 ` Andrea Righi
2008-05-21 15:14 ` Michael Halcrow
2008-05-21 15:39 ` Michael Halcrow [this message]
2008-05-21 22:59 ` Andrew Morton
2008-05-22 19:31 ` [PATCH] eCryptfs: Clean up kthread synchronization Michael Halcrow
2008-05-22 19:41 ` Andrew Morton
2008-05-22 21:16 ` Michael Halcrow
2008-05-22 21:44 ` [PATCH] eCryptfs: Use kthread_should_stop() instead of the non-empty list hack Michael Halcrow
2008-05-22 22:03 ` [PATCH] eCryptfs: Clean up kthread synchronization Andrew Morton
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=20080521153915.GA942@halcrowt61p.austin.ibm.com \
--to=mhalcrow@us.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=prussell@au1.ibm.com \
--cc=righiandr@users.sourceforge.net \
--cc=sergeh@us.ibm.com \
--cc=shaggy@us.ibm.com \
/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
all inboxes | Powered by JetHome®