Skip to contentSkip to conversation

Semaphore should be released in get_super

PATCH sdrb 2 participants 3 messages May 24, 2011 VFS

lore
Share & tools
lore

sdrb

author
#0 lore raw

Hello,

Probably I found a bug in get_super() proc. I think there should be semaphore released before return sb. I attached diff file.

regards,
sdrb

fs/super.c +3 -1
index c04f7e0..361bbec 100644
@@ -473,8 +473,10 @@ rescan:
 			spin_unlock(&sb_lock);
 			down_read(&sb->s_umount);
 			/* still alive? */
-			if (sb->s_root)
+			if (sb->s_root) {
+				up_read(&sb->s_umount);
 				return sb;
+			}
 			up_read(&sb->s_umount);
 			/* nope, got unmounted */
 			spin_lock(&sb_lock);
#1 lore raw
Quoted 4 lines · sdrb

Hello,

Probably I found a bug in get_super() proc. I think there should be semaphore released before return sb.

That's the point of get_super(). It's supposed to return with the semaphore held. Users call drop_super() later which releases the semaphore.

Signature · 4 lines
Matthew Wilcox				Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."
author
#2 lore raw
Quoted 9 lines · Matthew Wilcox
Quoted 4 lines · sdrb

Hello,

Probably I found a bug in get_super() proc. I think there should be semaphore released before return sb.

That's the point of get_super(). It's supposed to return with the semaphore held. Users call drop_super() later which releases the semaphore.

Sorry, my mistake - I noticed drop_user() just a few minutes after I sent a post :)