From: Sascha Hauer <s.hauer@pengutronix.de>
To: BAREBOX <barebox@lists.infradead.org>
Subject: [PATCH 2/3] fs: ext4: return an error pointer from ext_get_link()
Date: Mon, 02 Nov 2026 10:08:40 +0100 [thread overview]
Message-ID: <20261102-fs-getlink-fixes-v1-2-c2816b3f5ca8@pengutronix.de> (raw)
In-Reply-To: <20261102-fs-getlink-fixes-v1-0-c2816b3f5ca8@pengutronix.de>
ext_get_link() checks the result of ext4fs_read_file() for 0, which it
can't return here: the symlink is at least sizeof(inode.b.symlink) bytes
long, so it returns the full size or a negative error code. On an error,
the link is therefore returned with whatever was read into it, and
stays cached in inode->i_link.
Check for a negative return value instead and return it as an error
pointer, the way readlinkat() and path lookup expect it.
Fixes: 76cb57b4e1 ("fs: ext4: Switch to dentry cache implementation")
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
fs/ext4/ext_barebox.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/ext4/ext_barebox.c b/fs/ext4/ext_barebox.c
index 8f6802e94b..4035d5cf59 100644
--- a/fs/ext4/ext_barebox.c
+++ b/fs/ext4/ext_barebox.c
@@ -203,9 +203,10 @@ static const char *ext_get_link(struct dentry *dentry, struct inode *inode)
inode->i_link = dma_xzalloc(size_add(inode->i_size, 1));
ret = ext4fs_read_file(node, 0, inode->i_size, inode->i_link);
- if (ret == 0) {
+ if (ret < 0) {
free(inode->i_link);
inode->i_link = NULL;
+ return ERR_PTR(ret);
}
return inode->i_link;
--
2.47.3
next prev parent reply other threads:[~2026-11-02 9:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 9:08 [PATCH 0/3] fs: return error pointers from ->get_link() on failure Sascha Hauer
2026-11-02 9:08 ` [PATCH 1/3] fs: cramfs: return an error pointer from cramfs_get_link() Sascha Hauer
2026-11-02 9:08 ` Sascha Hauer [this message]
2026-11-02 9:08 ` [PATCH 3/3] fs: legacy: return an error pointer from legacy_get_link() Sascha Hauer
2026-11-02 10:21 ` [PATCH 0/3] fs: return error pointers from ->get_link() on failure Ahmad Fatoum
2026-11-02 14:29 ` Sascha Hauer
2026-11-02 13:25 ` Sascha Hauer
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=20261102-fs-getlink-fixes-v1-2-c2816b3f5ca8@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox