From: Gao Xiang <gaoxiang25@huawei.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
<devel@driverdev.osuosl.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
<linux-erofs@lists.ozlabs.org>, "Chao Yu" <yuchao0@huawei.com>,
Miao Xie <miaoxie@huawei.com>, <weidu.du@huawei.com>,
Dan Carpenter <dan.carpenter@oracle.com>,
Gao Xiang <gaoxiang25@huawei.com>
Subject: [PATCH v2 3/8] staging: erofs: complete error handing of z_erofs_map_blocks_iter
Date: Tue, 18 Sep 2018 22:25:35 +0800 [thread overview]
Message-ID: <1537280740-122019-4-git-send-email-gaoxiang25@huawei.com> (raw)
In-Reply-To: <1537280740-122019-1-git-send-email-gaoxiang25@huawei.com>
This patch completes error handing of z_erofs_map_blocks_iter
and vle_get_logical_extent_head, including no memory and
io error cases.
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
drivers/staging/erofs/unzip_vle.c | 35 ++++++++++++++++++++++++++---------
1 file changed, 26 insertions(+), 9 deletions(-)
diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c
index 1e89ff6..94c35b8 100644
--- a/drivers/staging/erofs/unzip_vle.c
+++ b/drivers/staging/erofs/unzip_vle.c
@@ -1500,7 +1500,11 @@ struct vle_map_blocks_iter_ctx {
unlock_page(mpage);
put_page(mpage);
- mpage = erofs_get_meta_page_nofail(ctx->sb, mblk, false);
+ mpage = erofs_get_meta_page(ctx->sb, mblk, false);
+ if (IS_ERR(mpage)) {
+ *ctx->mpage_ret = NULL;
+ return PTR_ERR(mpage);
+ }
*ctx->mpage_ret = mpage;
*ctx->kaddr_ret = kmap_atomic(mpage);
}
@@ -1511,9 +1515,12 @@ struct vle_map_blocks_iter_ctx {
switch (cluster_type) {
case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD:
delta0 = le16_to_cpu(di->di_u.delta[0]);
- DBG_BUGON(!delta0);
- DBG_BUGON(lcn < delta0);
-
+ if (unlikely(!delta0 || delta0 > lcn)) {
+ errln("invalid NONHEAD dl0 %u at lcn %u of nid %llu",
+ delta0, lcn, EROFS_V(ctx->inode)->nid);
+ DBG_BUGON(1);
+ return -EIO;
+ }
return vle_get_logical_extent_head(ctx,
lcn - delta0, ofs, pblk, flags);
case Z_EROFS_VLE_CLUSTER_TYPE_PLAIN:
@@ -1526,7 +1533,10 @@ struct vle_map_blocks_iter_ctx {
*pblk = le32_to_cpu(di->di_u.blkaddr);
break;
default:
- BUG_ON(1);
+ errln("unknown cluster type %u at lcn %u of nid %llu",
+ cluster_type, lcn, EROFS_V(ctx->inode)->nid);
+ DBG_BUGON(1);
+ return -EIO;
}
return 0;
}
@@ -1583,7 +1593,11 @@ int z_erofs_map_blocks_iter(struct inode *inode,
if (mpage != NULL)
put_page(mpage);
- mpage = erofs_get_meta_page_nofail(ctx.sb, mblk, false);
+ mpage = erofs_get_meta_page(ctx.sb, mblk, false);
+ if (IS_ERR(mpage)) {
+ err = PTR_ERR(mpage);
+ goto out;
+ }
*mpage_ret = mpage;
} else {
lock_page(mpage);
@@ -1646,8 +1660,11 @@ int z_erofs_map_blocks_iter(struct inode *inode,
&pblk, &map->m_flags);
mpage = *mpage_ret;
- if (unlikely(err))
- goto unmap_out;
+ if (unlikely(err)) {
+ if (mpage)
+ goto unmap_out;
+ goto out;
+ }
break;
default:
errln("unknown cluster type %u at offset %llu of nid %llu",
@@ -1671,7 +1688,7 @@ int z_erofs_map_blocks_iter(struct inode *inode,
map->m_llen, map->m_plen, map->m_flags);
/* aggressively BUG_ON iff CONFIG_EROFS_FS_DEBUG is on */
- DBG_BUGON(err < 0);
+ DBG_BUGON(err < 0 && err != -ENOMEM);
return err;
}
--
1.9.1
next prev parent reply other threads:[~2018-09-18 14:26 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-18 14:25 [PATCH v2 0/8] staging: erofs: error handing and more tracepoints Gao Xiang
2018-09-18 14:25 ` [PATCH v2 1/8] staging: erofs: fix a missing endian conversion Gao Xiang
2018-09-18 14:25 ` [PATCH v2 2/8] staging: erofs: clean up z_erofs_map_blocks_iter Gao Xiang
2018-09-18 14:25 ` Gao Xiang [this message]
2018-09-18 14:25 ` [PATCH v2 4/8] staging: erofs: fix a bug when appling cache strategy Gao Xiang
2018-09-18 14:27 ` [PATCH v2 5/8] staging: erofs: complete error handing of z_erofs_do_read_page Gao Xiang
2018-09-18 14:27 ` [PATCH v2 6/8] staging: erofs: avoid magic constants when initializing clusterbits Gao Xiang
2018-09-18 14:27 ` [PATCH v2 7/8] staging: erofs: add trace points for reading zipped data Gao Xiang
2018-09-18 14:27 ` [PATCH v2 8/8] staging: erofs: replace BUG_ON with DBG_BUGON in data.c Gao Xiang
2018-09-18 14:36 ` [PATCH v2 0/8] staging: erofs: error handing and more tracepoints Greg Kroah-Hartman
2018-09-18 14:38 ` Gao Xiang
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=1537280740-122019-4-git-send-email-gaoxiang25@huawei.com \
--to=gaoxiang25@huawei.com \
--cc=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miaoxie@huawei.com \
--cc=weidu.du@huawei.com \
--cc=yuchao0@huawei.com \
/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
all inboxes | Powered by JetHome®