ANDROID: sdcardfs: Check for NULL in revalidate
authorDaniel Rosenberg <drosen@google.com>
Mon, 22 May 2017 20:23:56 +0000 (13:23 -0700)
committerStricted <info@stricted.net>
Thu, 11 Oct 2018 16:03:41 +0000 (18:03 +0200)
If the inode is in the process of being evicted,
the top value may be NULL.

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

fs/sdcardfs/dentry.c

index 039c9530f861b982550363b52370a14c79f4e6b9..c8f3bcbfb183bfb2af1200b7da03b8917ab775ff 100644 (file)
@@ -109,14 +109,16 @@ static int sdcardfs_d_revalidate(struct dentry *dentry, unsigned int flags)
                goto out;
 
        /* If our top's inode is gone, we may be out of date */
-       inode = dentry->d_inode;
+       inode = igrab(dentry->d_inode);
        if (inode) {
                data = top_data_get(SDCARDFS_I(inode));
-               if (data->abandoned) {
+               if (!data || data->abandoned) {
                        d_drop(dentry);
                        err = 0;
                }
-               data_put(data);
+               if (data)
+                       data_put(data);
+               iput(inode);
        }
 
 out: