Skip to contentSkip to conversation

hpfs_setattr error case avoids unlock_kernel ?

PATCH In review Dr. David Alan Gilbert 3 participants 5 messages Dec 12, 2010 – Feb 7, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,
'sparse' pointed out to me the code in fs/hpfs/inode.c:hpfs_setattr
changed by Christoph's patch 1025774ce411f2bd4b059ad7b53f0003569b74fa 'remove inode_setattr', and it does look like the error path avoids an unlock_kernel (around like 284 of fs/hpfs/inode.c)

fs/hpfs/inode.c:265:5: warning: context imbalance in 'hpfs_setattr' - different lock contexts for basic block

--------------------------

       error = inode_change_ok(inode, attr);
        if (error)
                goto out_unlock;

        if ((attr->ia_valid & ATTR_SIZE) &&
            attr->ia_size != i_size_read(inode)) {
                error = vmtruncate(inode, attr->ia_size);
                if (error)
************            return error;
        }

        setattr_copy(inode, attr);
        mark_inode_dirty(inode);

        hpfs_write_inode(inode);

out_unlock:

        unlock_kernel();
        return error;

--------------------------

it looks like that 1st 'return error' needs to change into a goto out_unlock;

Dave

Signature · 4 lines
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\ gro.gilbert @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/
#1 lore raw
Quoted 1 line · Dr. David Alan Gilbert

it looks like that 1st 'return error' needs to change into a goto out_unlock;

Yes. Care to send a patch to fix it?

#2 lore raw

PATCH 1/1 hpfs_setattr error case avoids unlock_kernel

Quoted 4 lines · * Christoph Hellwig ([email protected]) wrote:
Quoted 1 line · Dr. David Alan Gilbert

it looks like that 1st 'return error' needs to change into a goto out_unlock;

Yes. Care to send a patch to fix it?

This fixed a case that 'sparse' spotted where hpfs_setattr has an error return that didn't go through it's path that unlocks.

This is against git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
version 6313e3c21743cc88bb5bd8aa72948ee1e83937b6.

Build tested only, I don't have an hpfs file system to test.

Dave

---

fs/hpfs/inode.c +1 -1
index 56f0da1..1ae35ba 100644
@@ -281,7 +281,7 @@ int hpfs_setattr(struct dentry *dentry, struct iattr *attr)
 	    attr->ia_size != i_size_read(inode)) {
 		error = vmtruncate(inode, attr->ia_size);
 		if (error)
-			return error;
+			goto out_unlock;
 	}
 
 	setattr_copy(inode, attr);
Signature · 4 lines
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\ gro.gilbert @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/
maintainer
#3 lore raw

Re: [PATCH] hpfs_setattr error case avoids unlock_kernel

ACK.

Mikulas

Quoted 39 lines · Dr. David Alan Gilbert
Quoted 4 lines · * Christoph Hellwig ([email protected]) wrote:
Quoted 1 line · Dr. David Alan Gilbert

it looks like that 1st 'return error' needs to change into a goto out_unlock;

Yes. Care to send a patch to fix it?

This fixed a case that 'sparse' spotted where hpfs_setattr has an error return that didn't go through it's path that unlocks.

This is against git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
version 6313e3c21743cc88bb5bd8aa72948ee1e83937b6.

Build tested only, I don't have an hpfs file system to test.

Dave

---

fs/hpfs/inode.c +1 -1
index 56f0da1..1ae35ba 100644
@@ -281,7 +281,7 @@ int hpfs_setattr(struct dentry *dentry, struct iattr *attr)
 	    attr->ia_size != i_size_read(inode)) {
 		error = vmtruncate(inode, attr->ia_size);
 		if (error)
-			return error;
+			goto out_unlock;
 	}
 
 	setattr_copy(inode, attr);
Signature · 4 lines
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\ gro.gilbert @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/
maintainer
#4 lore raw
In reply to Christoph Hellwig
Quoted 4 lines · Christoph Hellwig
Quoted 1 line · Dr. David Alan Gilbert

it looks like that 1st 'return error' needs to change into a goto out_unlock;

Yes. Care to send a patch to fix it?

Sorry, I am in a hospital and can't send anything. Do the patch yourself, please.

Mikulas