ext4_xattr: fix trying to read EA block even if it is absent
authorKaho Ng <ngkaho1234@gmail.com>
Mon, 27 Feb 2017 14:49:53 +0000 (22:49 +0800)
committerKaho Ng <ngkaho1234@gmail.com>
Mon, 27 Feb 2017 14:49:53 +0000 (22:49 +0800)
src/ext4_xattr.c

index 6e096438de7edd24abfc78b8035b594be36c18e1..bcddefb5fd20575d7fc2daf5b1d9cd510006edc9 100644 (file)
@@ -974,6 +974,13 @@ int ext4_xattr_get(struct ext4_inode_ref *inode_ref, uint8_t name_index,
                }
        } else {
                struct ext4_block block;
+
+               /* Return ENODATA if there is no EA block */
+               if (!xattr_block) {
+                       ret = ENODATA;
+                       goto out;
+               }
+
                block_finder.i = i;
                ret = ext4_trans_block_get(fs->bdev, &block, xattr_block);
                if (ret != EOK)