2019-09-09 15:07:01

by Ding Xiang

[permalink] [raw]
Subject: [PATCH] ovl: Fix dereferencing possible ERR_PTR()

if ovl_encode_real_fh() fails, no memory was allocated
and the error in the error-valued pointer should be returned.

Fixes: 9b6faee0747 ("ovl: check ERR_PTR() return value from ovl_encode_fh()")
Signed-off-by: Ding Xiang <[email protected]>
---
fs/overlayfs/export.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/overlayfs/export.c b/fs/overlayfs/export.c
index cb8ec1f..50ade19 100644
--- a/fs/overlayfs/export.c
+++ b/fs/overlayfs/export.c
@@ -229,7 +229,7 @@ static int ovl_d_to_fh(struct dentry *dentry, char *buf, int buflen)
ovl_dentry_upper(dentry), !enc_lower);
err = PTR_ERR(fh);
if (IS_ERR(fh))
- goto fail;
+ return err;

err = -EOVERFLOW;
if (fh->len > buflen)
--
1.9.1




2019-09-17 09:47:01

by Miklos Szeredi

[permalink] [raw]
Subject: Re: [PATCH] ovl: Fix dereferencing possible ERR_PTR()

On Mon, Sep 9, 2019 at 10:30 AM Ding Xiang
<[email protected]> wrote:
>
> if ovl_encode_real_fh() fails, no memory was allocated
> and the error in the error-valued pointer should be returned.

Applied, thanks.

Miklos