From: Yiyang Wu <toolmanp@tlmp.cc>
To: hsiangkao@linux.alibaba.com
Cc: linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org,
Yiyang Wu <toolmanp@tlmp.cc>, Al Viro <viro@zeniv.linux.org.uk>
Subject: [PATCH V2 1/2] erofs: use kmemdup_nul in erofs_fill_symlink
Date: Mon, 2 Sep 2024 15:00:46 +0800 [thread overview]
Message-ID: <20240902070047.384952-2-toolmanp@tlmp.cc> (raw)
In-Reply-To: <20240902070047.384952-1-toolmanp@tlmp.cc>
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>
---
fs/erofs/inode.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
index 419432be3223..d051afe39670 100644
--- a/fs/erofs/inode.c
+++ b/fs/erofs/inode.c
@@ -188,22 +188,20 @@ 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",
vi->nid);
DBG_BUGON(1);
return -EFSCORRUPTED;
}
- memcpy(lnk, kaddr + m_pofs, inode->i_size);
- lnk[inode->i_size] = '\0';
+
+ lnk = kmemdup_nul(kaddr + m_pofs, inode->i_size, GFP_KERNEL);
+
+ if (!lnk)
+ return -ENOMEM;
inode->i_link = lnk;
inode->i_op = &erofs_fast_symlink_iops;
--
2.46.0
next prev parent reply other threads:[~2024-09-02 7:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-02 7:00 [PATCH V2 0/2] erofs: refactor fast_symlink and read_inode Yiyang Wu
2024-09-02 7:00 ` Yiyang Wu [this message]
2024-09-02 7:11 ` [PATCH V2 1/2] erofs: use kmemdup_nul in erofs_fill_symlink Gao Xiang
2024-09-02 7:46 ` Yiyang Wu
2024-09-02 7:00 ` [PATCH V2 2/2] erofs: refactor read_inode calling convention Yiyang Wu
2024-09-02 7:18 ` Gao Xiang
2024-09-02 7:57 ` 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=20240902070047.384952-2-toolmanp@tlmp.cc \
--to=toolmanp@tlmp.cc \
--cc=hsiangkao@linux.alibaba.com \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox