提交 bea01ea0 编写于 作者: G Gao Xiang 提交者: Greg Kroah-Hartman

staging: erofs: {dir,inode,super}.c: rectify BUG_ONs

commit 8b987bca2d09649683cbe496419a011df8c08493 upstream.

remove all redundant BUG_ONs, and turn the rest
useful usages to DBG_BUGONs.
Signed-off-by: NGao Xiang <gaoxiang25@huawei.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 60ce4b52
...@@ -53,8 +53,11 @@ static int erofs_fill_dentries(struct dir_context *ctx, ...@@ -53,8 +53,11 @@ static int erofs_fill_dentries(struct dir_context *ctx,
strnlen(de_name, maxsize - nameoff) : strnlen(de_name, maxsize - nameoff) :
le16_to_cpu(de[1].nameoff) - nameoff; le16_to_cpu(de[1].nameoff) - nameoff;
/* the corrupted directory found */ /* a corrupted entry is found */
BUG_ON(de_namelen < 0); if (unlikely(de_namelen < 0)) {
DBG_BUGON(1);
return -EIO;
}
#ifdef CONFIG_EROFS_FS_DEBUG #ifdef CONFIG_EROFS_FS_DEBUG
dbg_namelen = min(EROFS_NAME_LEN - 1, de_namelen); dbg_namelen = min(EROFS_NAME_LEN - 1, de_namelen);
......
...@@ -132,7 +132,13 @@ static int fill_inline_data(struct inode *inode, void *data, unsigned m_pofs) ...@@ -132,7 +132,13 @@ static int fill_inline_data(struct inode *inode, void *data, unsigned m_pofs)
return -ENOMEM; return -ENOMEM;
m_pofs += vi->inode_isize + vi->xattr_isize; m_pofs += vi->inode_isize + vi->xattr_isize;
BUG_ON(m_pofs + inode->i_size > PAGE_SIZE);
/* inline symlink data shouldn't across page boundary as well */
if (unlikely(m_pofs + inode->i_size > PAGE_SIZE)) {
DBG_BUGON(1);
kfree(lnk);
return -EIO;
}
/* get in-page inline data */ /* get in-page inline data */
memcpy(lnk, data + m_pofs, inode->i_size); memcpy(lnk, data + m_pofs, inode->i_size);
...@@ -170,7 +176,7 @@ static int fill_inode(struct inode *inode, int isdir) ...@@ -170,7 +176,7 @@ static int fill_inode(struct inode *inode, int isdir)
return PTR_ERR(page); return PTR_ERR(page);
} }
BUG_ON(!PageUptodate(page)); DBG_BUGON(!PageUptodate(page));
data = page_address(page); data = page_address(page);
err = read_inode(inode, data + ofs); err = read_inode(inode, data + ofs);
......
...@@ -40,7 +40,6 @@ static int erofs_init_inode_cache(void) ...@@ -40,7 +40,6 @@ static int erofs_init_inode_cache(void)
static void erofs_exit_inode_cache(void) static void erofs_exit_inode_cache(void)
{ {
BUG_ON(erofs_inode_cachep == NULL);
kmem_cache_destroy(erofs_inode_cachep); kmem_cache_destroy(erofs_inode_cachep);
} }
...@@ -265,8 +264,8 @@ static int managed_cache_releasepage(struct page *page, gfp_t gfp_mask) ...@@ -265,8 +264,8 @@ static int managed_cache_releasepage(struct page *page, gfp_t gfp_mask)
int ret = 1; /* 0 - busy */ int ret = 1; /* 0 - busy */
struct address_space *const mapping = page->mapping; struct address_space *const mapping = page->mapping;
BUG_ON(!PageLocked(page)); DBG_BUGON(!PageLocked(page));
BUG_ON(mapping->a_ops != &managed_cache_aops); DBG_BUGON(mapping->a_ops != &managed_cache_aops);
if (PagePrivate(page)) if (PagePrivate(page))
ret = erofs_try_to_free_cached_page(mapping, page); ret = erofs_try_to_free_cached_page(mapping, page);
...@@ -279,10 +278,10 @@ static void managed_cache_invalidatepage(struct page *page, ...@@ -279,10 +278,10 @@ static void managed_cache_invalidatepage(struct page *page,
{ {
const unsigned int stop = length + offset; const unsigned int stop = length + offset;
BUG_ON(!PageLocked(page)); DBG_BUGON(!PageLocked(page));
/* Check for overflow */ /* Check for potential overflow in debug mode */
BUG_ON(stop > PAGE_SIZE || stop < length); DBG_BUGON(stop > PAGE_SIZE || stop < length);
if (offset == 0 && stop == PAGE_SIZE) if (offset == 0 && stop == PAGE_SIZE)
while (!managed_cache_releasepage(page, GFP_NOFS)) while (!managed_cache_releasepage(page, GFP_NOFS))
...@@ -619,7 +618,7 @@ static int erofs_show_options(struct seq_file *seq, struct dentry *root) ...@@ -619,7 +618,7 @@ static int erofs_show_options(struct seq_file *seq, struct dentry *root)
static int erofs_remount(struct super_block *sb, int *flags, char *data) static int erofs_remount(struct super_block *sb, int *flags, char *data)
{ {
BUG_ON(!sb_rdonly(sb)); DBG_BUGON(!sb_rdonly(sb));
*flags |= SB_RDONLY; *flags |= SB_RDONLY;
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册