]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
ovl: Fix dereferencing possible ERR_PTR()
authorDing Xiang <dingxiang@cmss.chinamobile.com>
Mon, 9 Sep 2019 08:29:56 +0000 (16:29 +0800)
committerMiklos Szeredi <mszeredi@redhat.com>
Wed, 11 Sep 2019 14:11:45 +0000 (16:11 +0200)
if ovl_encode_real_fh() fails, no memory was allocated
and the error in the error-valued pointer should be returned.

Fixes: 9b6faee07470 ("ovl: check ERR_PTR() return value from ovl_encode_fh()")
Signed-off-by: Ding Xiang <dingxiang@cmss.chinamobile.com>
Cc: <stable@vger.kernel.org> # v4.16+
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/overlayfs/export.c

index cb8ec1f65c030b8164f859019adf8941d51d76ab..73c9775215b33ba043468f57d6cb618fbcffe477 100644 (file)
@@ -227,9 +227,8 @@ static int ovl_d_to_fh(struct dentry *dentry, char *buf, int buflen)
        /* Encode an upper or lower file handle */
        fh = ovl_encode_real_fh(enc_lower ? ovl_dentry_lower(dentry) :
                                ovl_dentry_upper(dentry), !enc_lower);
-       err = PTR_ERR(fh);
        if (IS_ERR(fh))
-               goto fail;
+               return PTR_ERR(fh);
 
        err = -EOVERFLOW;
        if (fh->len > buflen)