All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] fs/ext4/xattr: check the return value of ext4_xattr_inode_dec_ref()
@ 2022-09-09  4:47 Li Zhong
  2022-09-10  9:55 ` Ojaswin Mujoo
  0 siblings, 1 reply; 3+ messages in thread
From: Li Zhong @ 2022-09-09  4:47 UTC (permalink / raw)
  To: linux-kernel, linux-ext4; +Cc: adilger.kernel, tytso, Li Zhong

Check the return value of ext4_xattr_inode_dec_ref(), which could return
error code and need to be warned.

Signed-off-by: Li Zhong <floridsleeves@gmail.com>
---
 fs/ext4/xattr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 533216e80fa2..76141ed12bc2 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -1540,7 +1540,9 @@ static int ext4_xattr_inode_lookup_create(handle_t *handle, struct inode *inode,
 
 	err = ext4_xattr_inode_write(handle, ea_inode, value, value_len);
 	if (err) {
-		ext4_xattr_inode_dec_ref(handle, ea_inode);
+		err = ext4_xattr_inode_dec_ref(handle, ea_inode);
+		if (err)
+			ext4_warning_inode(ea_inode, "cleanup dec ref error %d", err);
 		iput(ea_inode);
 		return err;
 	}
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] fs/ext4/xattr: check the return value of ext4_xattr_inode_dec_ref()
  2022-09-09  4:47 [PATCH v1] fs/ext4/xattr: check the return value of ext4_xattr_inode_dec_ref() Li Zhong
@ 2022-09-10  9:55 ` Ojaswin Mujoo
  2022-09-17  0:25   ` Li Zhong
  0 siblings, 1 reply; 3+ messages in thread
From: Ojaswin Mujoo @ 2022-09-10  9:55 UTC (permalink / raw)
  To: Li Zhong; +Cc: linux-kernel, linux-ext4, adilger.kernel, tytso

On Thu, Sep 08, 2022 at 09:47:27PM -0700, Li Zhong wrote:
> Check the return value of ext4_xattr_inode_dec_ref(), which could return
> error code and need to be warned.
> 
> Signed-off-by: Li Zhong <floridsleeves@gmail.com>
> ---
>  fs/ext4/xattr.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
> index 533216e80fa2..76141ed12bc2 100644
> --- a/fs/ext4/xattr.c
> +++ b/fs/ext4/xattr.c
> @@ -1540,7 +1540,9 @@ static int ext4_xattr_inode_lookup_create(handle_t *handle, struct inode *inode,
>  
>  	err = ext4_xattr_inode_write(handle, ea_inode, value, value_len);
>  	if (err) {
> -		ext4_xattr_inode_dec_ref(handle, ea_inode);
> +		err = ext4_xattr_inode_dec_ref(handle, ea_inode);
Hey Li,

My only concern here is in case ext4_xattr_inode_dec_ref() fails, we
overwrite the err value and the actual err from ext4_xattr_inode_write() 
is lost.

I feel the ext4_xattr_inode_write() error code would be more valuable
for the calling function hence that is the one we should propogate.  
Maybe we can just print the warning without overwriting err? 

Regards,
Ojaswin
> +		if (err)
> +			ext4_warning_inode(ea_inode, "cleanup dec ref error %d", err);
>  		iput(ea_inode);
>  		return err;
>  	}
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] fs/ext4/xattr: check the return value of ext4_xattr_inode_dec_ref()
  2022-09-10  9:55 ` Ojaswin Mujoo
@ 2022-09-17  0:25   ` Li Zhong
  0 siblings, 0 replies; 3+ messages in thread
From: Li Zhong @ 2022-09-17  0:25 UTC (permalink / raw)
  To: Ojaswin Mujoo; +Cc: linux-kernel, linux-ext4, adilger.kernel, tytso

On Sat, Sep 10, 2022 at 2:55 AM Ojaswin Mujoo <ojaswin@linux.ibm.com> wrote:
>
> On Thu, Sep 08, 2022 at 09:47:27PM -0700, Li Zhong wrote:
> > Check the return value of ext4_xattr_inode_dec_ref(), which could return
> > error code and need to be warned.
> >
> > Signed-off-by: Li Zhong <floridsleeves@gmail.com>
> > ---
> >  fs/ext4/xattr.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
> > index 533216e80fa2..76141ed12bc2 100644
> > --- a/fs/ext4/xattr.c
> > +++ b/fs/ext4/xattr.c
> > @@ -1540,7 +1540,9 @@ static int ext4_xattr_inode_lookup_create(handle_t *handle, struct inode *inode,
> >
> >       err = ext4_xattr_inode_write(handle, ea_inode, value, value_len);
> >       if (err) {
> > -             ext4_xattr_inode_dec_ref(handle, ea_inode);
> > +             err = ext4_xattr_inode_dec_ref(handle, ea_inode);
> Hey Li,
>
> My only concern here is in case ext4_xattr_inode_dec_ref() fails, we
> overwrite the err value and the actual err from ext4_xattr_inode_write()
> is lost.
>
> I feel the ext4_xattr_inode_write() error code would be more valuable
> for the calling function hence that is the one we should propogate.
> Maybe we can just print the warning without overwriting err?
>
Thanks for pointing this out! I'll fix it in v2 patch.
>
> Regards,
> Ojaswin
> > +             if (err)
> > +                     ext4_warning_inode(ea_inode, "cleanup dec ref error %d", err);
> >               iput(ea_inode);
> >               return err;
> >       }
> > --
> > 2.25.1
> >

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-09-17  0:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-09  4:47 [PATCH v1] fs/ext4/xattr: check the return value of ext4_xattr_inode_dec_ref() Li Zhong
2022-09-10  9:55 ` Ojaswin Mujoo
2022-09-17  0:25   ` Li Zhong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.