* [PATCH 0/2] ubifs: Adjustments for ubifs_purge_xattrs() @ 2024-09-26 9:48 Markus Elfring 2024-09-26 9:49 ` [PATCH 1/2] ubifs: Call iput(xino) only once in ubifs_purge_xattrs() Markus Elfring 2024-09-26 9:50 ` [PATCH 2/2] ubifs: Reduce kfree() calls " Markus Elfring 0 siblings, 2 replies; 5+ messages in thread From: Markus Elfring @ 2024-09-26 9:48 UTC (permalink / raw) To: linux-mtd, Richard Weinberger, Zhihao Cheng; +Cc: LKML, kernel-janitors From: Markus Elfring <elfring@users.sourceforge.net> Date: Thu, 26 Sep 2024 11:38:22 +0200 A few update suggestions were taken into account from static source code analysis. Markus Elfring (2): Call iput(xino) only once Reduce kfree() calls fs/ubifs/xattr.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) -- 2.46.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] ubifs: Call iput(xino) only once in ubifs_purge_xattrs() 2024-09-26 9:48 [PATCH 0/2] ubifs: Adjustments for ubifs_purge_xattrs() Markus Elfring @ 2024-09-26 9:49 ` Markus Elfring 2024-09-26 11:12 ` Zhihao Cheng 2024-09-26 9:50 ` [PATCH 2/2] ubifs: Reduce kfree() calls " Markus Elfring 1 sibling, 1 reply; 5+ messages in thread From: Markus Elfring @ 2024-09-26 9:49 UTC (permalink / raw) To: linux-mtd, Richard Weinberger, Zhihao Cheng; +Cc: LKML, kernel-janitors From: Markus Elfring <elfring@users.sourceforge.net> Date: Thu, 26 Sep 2024 11:05:29 +0200 An iput(xino) call was immediately used after a return value check for a remove_xattr() call in this function implementation. Thus call such a function only once instead directly before the check. This issue was transformed by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- fs/ubifs/xattr.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c index f734588b224a..7757959e9f09 100644 --- a/fs/ubifs/xattr.c +++ b/fs/ubifs/xattr.c @@ -541,16 +541,14 @@ int ubifs_purge_xattrs(struct inode *host) clear_nlink(xino); err = remove_xattr(c, host, xino, &nm); + iput(xino); if (err) { kfree(pxent); kfree(xent); - iput(xino); ubifs_err(c, "cannot remove xattr, error %d", err); goto out_err; } - iput(xino); - kfree(pxent); pxent = xent; key_read(c, &xent->key, &key); -- 2.46.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] ubifs: Call iput(xino) only once in ubifs_purge_xattrs() 2024-09-26 9:49 ` [PATCH 1/2] ubifs: Call iput(xino) only once in ubifs_purge_xattrs() Markus Elfring @ 2024-09-26 11:12 ` Zhihao Cheng 0 siblings, 0 replies; 5+ messages in thread From: Zhihao Cheng @ 2024-09-26 11:12 UTC (permalink / raw) To: Markus Elfring, linux-mtd, Richard Weinberger; +Cc: LKML, kernel-janitors 在 2024/9/26 17:49, Markus Elfring 写道: > From: Markus Elfring <elfring@users.sourceforge.net> > Date: Thu, 26 Sep 2024 11:05:29 +0200 > > An iput(xino) call was immediately used after a return value check > for a remove_xattr() call in this function implementation. > Thus call such a function only once instead directly before the check. > > This issue was transformed by using the Coccinelle software. > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> > --- > fs/ubifs/xattr.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com> > diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c > index f734588b224a..7757959e9f09 100644 > --- a/fs/ubifs/xattr.c > +++ b/fs/ubifs/xattr.c > @@ -541,16 +541,14 @@ int ubifs_purge_xattrs(struct inode *host) > > clear_nlink(xino); > err = remove_xattr(c, host, xino, &nm); > + iput(xino); > if (err) { > kfree(pxent); > kfree(xent); > - iput(xino); > ubifs_err(c, "cannot remove xattr, error %d", err); > goto out_err; > } > > - iput(xino); > - > kfree(pxent); > pxent = xent; > key_read(c, &xent->key, &key); > -- > 2.46.1 > > . > ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] ubifs: Reduce kfree() calls in ubifs_purge_xattrs() 2024-09-26 9:48 [PATCH 0/2] ubifs: Adjustments for ubifs_purge_xattrs() Markus Elfring 2024-09-26 9:49 ` [PATCH 1/2] ubifs: Call iput(xino) only once in ubifs_purge_xattrs() Markus Elfring @ 2024-09-26 9:50 ` Markus Elfring 2024-09-26 11:13 ` Zhihao Cheng 1 sibling, 1 reply; 5+ messages in thread From: Markus Elfring @ 2024-09-26 9:50 UTC (permalink / raw) To: linux-mtd, Richard Weinberger, Zhihao Cheng; +Cc: LKML, kernel-janitors From: Markus Elfring <elfring@users.sourceforge.net> Date: Thu, 26 Sep 2024 11:28:48 +0200 Move a pair of kfree() calls behind the label “out_err” so that two statements can be better reused at the end of this function implementation. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- fs/ubifs/xattr.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c index 7757959e9f09..a514dc4dc535 100644 --- a/fs/ubifs/xattr.c +++ b/fs/ubifs/xattr.c @@ -532,8 +532,6 @@ int ubifs_purge_xattrs(struct inode *host) ubifs_err(c, "dead directory entry '%s', error %d", xent->name, err); ubifs_ro_mode(c, err); - kfree(pxent); - kfree(xent); goto out_err; } @@ -543,8 +541,6 @@ int ubifs_purge_xattrs(struct inode *host) err = remove_xattr(c, host, xino, &nm); iput(xino); if (err) { - kfree(pxent); - kfree(xent); ubifs_err(c, "cannot remove xattr, error %d", err); goto out_err; } @@ -564,6 +560,8 @@ int ubifs_purge_xattrs(struct inode *host) return 0; out_err: + kfree(pxent); + kfree(xent); up_write(&ubifs_inode(host)->xattr_sem); return err; } -- 2.46.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] ubifs: Reduce kfree() calls in ubifs_purge_xattrs() 2024-09-26 9:50 ` [PATCH 2/2] ubifs: Reduce kfree() calls " Markus Elfring @ 2024-09-26 11:13 ` Zhihao Cheng 0 siblings, 0 replies; 5+ messages in thread From: Zhihao Cheng @ 2024-09-26 11:13 UTC (permalink / raw) To: Markus Elfring, linux-mtd, Richard Weinberger; +Cc: LKML, kernel-janitors 在 2024/9/26 17:50, Markus Elfring 写道: > From: Markus Elfring <elfring@users.sourceforge.net> > Date: Thu, 26 Sep 2024 11:28:48 +0200 > > Move a pair of kfree() calls behind the label “out_err” > so that two statements can be better reused at the end of > this function implementation. > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> > --- > fs/ubifs/xattr.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com> > diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c > index 7757959e9f09..a514dc4dc535 100644 > --- a/fs/ubifs/xattr.c > +++ b/fs/ubifs/xattr.c > @@ -532,8 +532,6 @@ int ubifs_purge_xattrs(struct inode *host) > ubifs_err(c, "dead directory entry '%s', error %d", > xent->name, err); > ubifs_ro_mode(c, err); > - kfree(pxent); > - kfree(xent); > goto out_err; > } > > @@ -543,8 +541,6 @@ int ubifs_purge_xattrs(struct inode *host) > err = remove_xattr(c, host, xino, &nm); > iput(xino); > if (err) { > - kfree(pxent); > - kfree(xent); > ubifs_err(c, "cannot remove xattr, error %d", err); > goto out_err; > } > @@ -564,6 +560,8 @@ int ubifs_purge_xattrs(struct inode *host) > return 0; > > out_err: > + kfree(pxent); > + kfree(xent); > up_write(&ubifs_inode(host)->xattr_sem); > return err; > } > -- > 2.46.1 > > . > ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-09-26 11:13 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-09-26 9:48 [PATCH 0/2] ubifs: Adjustments for ubifs_purge_xattrs() Markus Elfring 2024-09-26 9:49 ` [PATCH 1/2] ubifs: Call iput(xino) only once in ubifs_purge_xattrs() Markus Elfring 2024-09-26 11:12 ` Zhihao Cheng 2024-09-26 9:50 ` [PATCH 2/2] ubifs: Reduce kfree() calls " Markus Elfring 2024-09-26 11:13 ` Zhihao Cheng
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox