* [PATCH] erofs-utils: lib: fix dropped inode buffer write errors
@ 2026-04-20 18:02 Vansh Choudhary
0 siblings, 0 replies; only message in thread
From: Vansh Choudhary @ 2026-04-20 18:02 UTC (permalink / raw)
To: linux-erofs; +Cc: Vansh Choudhary
erofs_mkfs_handle_nondirectory() discards the return values of
erofs_prepare_inode_buffer() and erofs_write_tail_end() and always
returns 0, so ENOSPC, ENOMEM, and tail-write I/O errors silently
produce a corrupt image.
Return those errors to the caller. Fix the same dropped returns in
erofs_mkfs_jobfn() and erofs_mkfs_build_special_from_fd().
Signed-off-by: Vansh Choudhary <ch@vnsh.in>
---
lib/inode.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/lib/inode.c b/lib/inode.c
index 95fd93b..b3e5f62 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -1574,9 +1574,10 @@ static int erofs_mkfs_handle_nondirectory(const struct erofs_mkfs_btctx *btctx,
}
if (ret)
return ret;
- erofs_prepare_inode_buffer(btctx->im, inode);
- erofs_write_tail_end(btctx->im, inode);
- return 0;
+ ret = erofs_prepare_inode_buffer(btctx->im, inode);
+ if (ret)
+ return ret;
+ return erofs_write_tail_end(btctx->im, inode);
}
static int erofs_mkfs_create_directory(const struct erofs_mkfs_btctx *ctx,
@@ -1650,7 +1651,9 @@ static int erofs_mkfs_jobfn(const struct erofs_mkfs_btctx *ctx,
ret = erofs_write_dir_file(ctx->im, inode);
if (ret)
return ret;
- erofs_write_tail_end(ctx->im, inode);
+ ret = erofs_write_tail_end(ctx->im, inode);
+ if (ret)
+ return ret;
inode->bh->op = &erofs_write_inode_bhops;
erofs_iput(inode);
return 0;
@@ -2406,8 +2409,12 @@ struct erofs_inode *erofs_mkfs_build_special_from_fd(struct erofs_importer *im,
if (ret)
return ERR_PTR(ret);
out:
- erofs_prepare_inode_buffer(im, inode);
- erofs_write_tail_end(im, inode);
+ ret = erofs_prepare_inode_buffer(im, inode);
+ if (ret)
+ return ERR_PTR(ret);
+ ret = erofs_write_tail_end(im, inode);
+ if (ret)
+ return ERR_PTR(ret);
return inode;
}
--
2.43.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-04-20 18:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-20 18:02 [PATCH] erofs-utils: lib: fix dropped inode buffer write errors Vansh Choudhary
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox