Coverity-id: 647269
Signed-off-by: Gao Xiang <[email protected]>
---
lib/metabox.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lib/metabox.c b/lib/metabox.c
index 86a708367dc0..5c2eadacaf7f 100644
--- a/lib/metabox.c
+++ b/lib/metabox.c
@@ -133,6 +133,10 @@ int erofs_metazone_flush(struct erofs_sb_info *sbi)
return PTR_ERR(bh);
erofs_mapbh(NULL, bh->block);
pos_out = erofs_btell(bh, false);
+ if (__erofs_unlikely(pos_out == EROFS_NULL_ADDR)) {
+ erofs_bdrop(bh, true);
+ return -EFAULT;
+ }
meta_blkaddr = pos_out >> sbi->blkszbits;
sbi->metazone_startblk = meta_blkaddr;
@@ -148,7 +152,7 @@ int erofs_metazone_flush(struct erofs_sb_info *sbi)
do {
count = min_t(erofs_off_t, length, INT_MAX);
- ret = erofs_io_xcopy(sbi->bmgr->vf, pos_out,
+ ret = erofs_io_xcopy(sbi->bmgr->vf, (off_t)pos_out,
&m2gr->vf, count, false);
if (ret < 0)
break;
--
2.43.5