Skip to content

Commit

Permalink
ovl: Fix dereferencing possible ERR_PTR()
Browse files Browse the repository at this point in the history
if ovl_encode_real_fh() fails, no memory was allocated
and the error in the error-valued pointer should be returned.

Fixes: 9b6faee ("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>
  • Loading branch information
Ding Xiang authored and Miklos Szeredi committed Sep 11, 2019
1 parent 0be0bfd commit 97f024b
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions fs/overlayfs/export.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 97f024b

Please sign in to comment.