From: Gao Xiang via Linux-erofs <linux-erofs@lists.ozlabs.org>
To: Gao Xiang <hsiangkao@linux.alibaba.com>
Cc: linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org,
Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH V4 1/2] erofs: use kmemdup_nul in erofs_fill_symlink
Date: Mon, 2 Sep 2024 17:04:50 +0800 [thread overview]
Message-ID: <ZtV/speqypBt99sE@debian> (raw)
In-Reply-To: <5783ccbd-34cb-4f1b-8376-d795df2db4e3@linux.alibaba.com>
On Mon, Sep 02, 2024 at 04:52:30PM +0800, Gao Xiang wrote:
>
>
> On 2024/9/2 16:31, Yiyang Wu wrote:
> > Remove open coding in erofs_fill_symlink.
> >
> > Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
> > Link: https://lore.kernel.org/all/20240425222847.GN2118490@ZenIV
> > Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc>
>
> If a patch is unchanged, you have two ways to handle:
> - resend the patch with new received "Reviewed-by";
> - just send the updated [PATCH 2/2] with new version
> and `--in-reply-to=<old message id>`.
>
> I will apply this patch first.
I applied this patch as
From b3c5375ceb2944a7e4d34a6fb106ecd4614260d7 Mon Sep 17 00:00:00 2001
From: Yiyang Wu <toolmanp@tlmp.cc>
Date: Mon, 2 Sep 2024 16:31:46 +0800
Subject: erofs: use kmemdup_nul in erofs_fill_symlink
Remove open coding in erofs_fill_symlink.
Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
Link: https://lore.kernel.org/all/20240425222847.GN2118490@ZenIV
Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc>
Link: https://lore.kernel.org/r/20240902083147.450558-2-toolmanp@tlmp.cc
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
fs/erofs/inode.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
index 82259553d9f641..68ea67e0caf33a 100644
--- a/fs/erofs/inode.c
+++ b/fs/erofs/inode.c
@@ -179,7 +179,6 @@ static int erofs_fill_symlink(struct inode *inode,
void *kaddr,
{
struct erofs_inode *vi = EROFS_I(inode);
unsigned int bsz = i_blocksize(inode);
- char *lnk;
/* if it cannot be handled with fast symlink scheme */
if (vi->datalayout != EROFS_INODE_FLAT_INLINE ||
@@ -188,24 +187,18 @@ static int erofs_fill_symlink(struct inode *inode,
void *kaddr,
return 0;
}
- lnk = kmalloc(inode->i_size + 1, GFP_KERNEL);
- if (!lnk)
- return -ENOMEM;
-
m_pofs += vi->xattr_isize;
/* inline symlink data shouldn't cross block boundary */
if (m_pofs + inode->i_size > bsz) {
- kfree(lnk);
- erofs_err(inode->i_sb,
- "inline data cross block boundary @ nid %llu",
+ erofs_err(inode->i_sb, "inline data cross block boundary
@ nid %llu",
vi->nid);
DBG_BUGON(1);
return -EFSCORRUPTED;
}
- memcpy(lnk, kaddr + m_pofs, inode->i_size);
- lnk[inode->i_size] = '\0';
- inode->i_link = lnk;
+ inode->i_link = kmemdup_nul(kaddr + m_pofs, inode->i_size,
GFP_KERNEL);
+ if (!inode->i_link)
+ return -ENOMEM;
inode->i_op = &erofs_fast_symlink_iops;
return 0;
}
To fix a redundant tab and a blank line.
Thanks,
Gao Xiang
WARNING: multiple messages have this Message-ID (diff)
From: Gao Xiang <xiang@kernel.org>
To: Gao Xiang <hsiangkao@linux.alibaba.com>
Cc: Yiyang Wu <toolmanp@tlmp.cc>,
linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org,
Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH V4 1/2] erofs: use kmemdup_nul in erofs_fill_symlink
Date: Mon, 2 Sep 2024 17:04:50 +0800 [thread overview]
Message-ID: <ZtV/speqypBt99sE@debian> (raw)
In-Reply-To: <5783ccbd-34cb-4f1b-8376-d795df2db4e3@linux.alibaba.com>
On Mon, Sep 02, 2024 at 04:52:30PM +0800, Gao Xiang wrote:
>
>
> On 2024/9/2 16:31, Yiyang Wu wrote:
> > Remove open coding in erofs_fill_symlink.
> >
> > Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
> > Link: https://lore.kernel.org/all/20240425222847.GN2118490@ZenIV
> > Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc>
>
> If a patch is unchanged, you have two ways to handle:
> - resend the patch with new received "Reviewed-by";
> - just send the updated [PATCH 2/2] with new version
> and `--in-reply-to=<old message id>`.
>
> I will apply this patch first.
I applied this patch as
From b3c5375ceb2944a7e4d34a6fb106ecd4614260d7 Mon Sep 17 00:00:00 2001
From: Yiyang Wu <toolmanp@tlmp.cc>
Date: Mon, 2 Sep 2024 16:31:46 +0800
Subject: erofs: use kmemdup_nul in erofs_fill_symlink
Remove open coding in erofs_fill_symlink.
Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
Link: https://lore.kernel.org/all/20240425222847.GN2118490@ZenIV
Signed-off-by: Yiyang Wu <toolmanp@tlmp.cc>
Link: https://lore.kernel.org/r/20240902083147.450558-2-toolmanp@tlmp.cc
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
fs/erofs/inode.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
index 82259553d9f641..68ea67e0caf33a 100644
--- a/fs/erofs/inode.c
+++ b/fs/erofs/inode.c
@@ -179,7 +179,6 @@ static int erofs_fill_symlink(struct inode *inode,
void *kaddr,
{
struct erofs_inode *vi = EROFS_I(inode);
unsigned int bsz = i_blocksize(inode);
- char *lnk;
/* if it cannot be handled with fast symlink scheme */
if (vi->datalayout != EROFS_INODE_FLAT_INLINE ||
@@ -188,24 +187,18 @@ static int erofs_fill_symlink(struct inode *inode,
void *kaddr,
return 0;
}
- lnk = kmalloc(inode->i_size + 1, GFP_KERNEL);
- if (!lnk)
- return -ENOMEM;
-
m_pofs += vi->xattr_isize;
/* inline symlink data shouldn't cross block boundary */
if (m_pofs + inode->i_size > bsz) {
- kfree(lnk);
- erofs_err(inode->i_sb,
- "inline data cross block boundary @ nid %llu",
+ erofs_err(inode->i_sb, "inline data cross block boundary
@ nid %llu",
vi->nid);
DBG_BUGON(1);
return -EFSCORRUPTED;
}
- memcpy(lnk, kaddr + m_pofs, inode->i_size);
- lnk[inode->i_size] = '\0';
- inode->i_link = lnk;
+ inode->i_link = kmemdup_nul(kaddr + m_pofs, inode->i_size,
GFP_KERNEL);
+ if (!inode->i_link)
+ return -ENOMEM;
inode->i_op = &erofs_fast_symlink_iops;
return 0;
}
To fix a redundant tab and a blank line.
Thanks,
Gao Xiang
next prev parent reply other threads:[~2024-09-02 9:05 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-02 8:31 [PATCH V4 0/2] erofs: refactor fast_symlink and read_inode Yiyang Wu via Linux-erofs
2024-09-02 8:31 ` Yiyang Wu
2024-09-02 8:31 ` [PATCH V4 1/2] erofs: use kmemdup_nul in erofs_fill_symlink Yiyang Wu via Linux-erofs
2024-09-02 8:31 ` Yiyang Wu
2024-09-02 8:52 ` Gao Xiang
2024-09-02 9:04 ` Gao Xiang via Linux-erofs [this message]
2024-09-02 9:04 ` Gao Xiang
2024-09-09 3:37 ` Chao Yu via Linux-erofs
2024-09-09 3:37 ` Chao Yu
2024-09-02 8:31 ` [PATCH V4 2/2] erofs: refactor read_inode calling convention Yiyang Wu via Linux-erofs
2024-09-02 8:31 ` Yiyang Wu
2024-09-02 8:53 ` Gao Xiang
2024-09-02 9:34 ` Yiyang Wu via Linux-erofs
2024-09-02 9:34 ` Yiyang Wu
2024-09-02 9:54 ` Gao Xiang
2024-09-03 2:37 ` Gao Xiang via Linux-erofs
2024-09-03 2:37 ` Gao Xiang
2024-09-09 3:41 ` Chao Yu via Linux-erofs
2024-09-09 3:41 ` Chao Yu
2024-09-02 9:36 ` Yiyang Wu via Linux-erofs
2024-09-02 9:36 ` Yiyang Wu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZtV/speqypBt99sE@debian \
--to=linux-erofs@lists.ozlabs.org \
--cc=hsiangkao@linux.alibaba.com \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=xiang@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.