From: Vansh Choudhary <ch@vnsh.in>
To: linux-erofs@lists.ozlabs.org
Cc: Vansh Choudhary <ch@vnsh.in>
Subject: [PATCH] erofs-utils: lib: fix dropped inode buffer write errors
Date: Mon, 20 Apr 2026 23:32:56 +0530 [thread overview]
Message-ID: <20260420180335.56064-1-ch@vnsh.in> (raw)
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
reply other threads:[~2026-04-20 18:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260420180335.56064-1-ch@vnsh.in \
--to=ch@vnsh.in \
--cc=linux-erofs@lists.ozlabs.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