[PATCH v2 3/4] fs: ext4: return an error pointer from ext_get_link()
Sascha Hauer
s.hauer at pengutronix.de
Mon Nov 2 01:31:22 PST 2026
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 at 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
More information about the barebox
mailing list