hostfs: Freeing an ERR_PTR in hostfs_fill_sb_common()
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 13 Jul 2016 10:12:34 +0000 (13:12 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 30 Sep 2016 08:18:39 +0000 (10:18 +0200)
commit 8a545f185145e3c09348cd74326268ecfc6715a3 upstream.

We can't pass error pointers to kfree() or it causes an oops.

Fixes: 52b209f7b848 ('get rid of hostfs_read_inode()')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/hostfs/hostfs_kern.c

index 5a7b3229b956ea99fe57b1e88f7d8234b5fee690..f34d6f5a5aca38d01043f9c94f67359f9cf84528 100644 (file)
@@ -959,10 +959,11 @@ static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent)
 
        if (S_ISLNK(root_inode->i_mode)) {
                char *name = follow_link(host_root_path);
-               if (IS_ERR(name))
+               if (IS_ERR(name)) {
                        err = PTR_ERR(name);
-               else
-                       err = read_name(root_inode, name);
+                       goto out_put;
+               }
+               err = read_name(root_inode, name);
                kfree(name);
                if (err)
                        goto out_put;