ANDROID: sdcardfs: Don't iput if we didn't igrab
authorDaniel Roseberg <drosen@google.com>
Tue, 9 May 2017 20:36:35 +0000 (13:36 -0700)
committerAmit Pundir <amit.pundir@linaro.org>
Thu, 25 May 2017 11:07:25 +0000 (16:37 +0530)
If we fail to get top, top is either NULL, or igrab found
that we're in the process of freeing that inode, and did
not grab it. Either way, we didn't grab it, and have no
business putting it.

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 38117720
Change-Id: Ie2f587483b9abb5144263156a443e89bc69b767b

fs/sdcardfs/inode.c

index f15cb11ca8fd511bc5d0321965d23e6024c05054..4f09eebd7d95beda972d12052f47f20f7bbf1c38 100644 (file)
@@ -618,11 +618,8 @@ static int sdcardfs_permission(struct vfsmount *mnt, struct inode *inode, int ma
        struct inode tmp;
        struct inode *top = grab_top(SDCARDFS_I(inode));
 
-       if (!top) {
-               release_top(SDCARDFS_I(inode));
-               WARN(1, "Top value was null!\n");
+       if (!top)
                return -EINVAL;
-       }
 
        /*
         * Permission check on sdcardfs inode.
@@ -696,10 +693,8 @@ static int sdcardfs_setattr(struct vfsmount *mnt, struct dentry *dentry, struct
        inode = d_inode(dentry);
        top = grab_top(SDCARDFS_I(inode));
 
-       if (!top) {
-               release_top(SDCARDFS_I(inode));
+       if (!top)
                return -EINVAL;
-       }
 
        /*
         * Permission check on sdcardfs inode.