mirror of
https://github.com/torvalds/linux.git
synced 2024-11-11 06:31:49 +00:00
f2fs: avoid BUG_ON from check_nid_range and update return path in do_read_inode
In function check_nid_range, there is no need to trigger BUG_ON and make kernel stop. Instead it could just check and indicate the inode number to be EINVAL. Update the return path in do_read_inode to use the return from check_nid_range. Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com> Signed-off-by: Amit Sahrawat <a.sahrawat@samsung.com> [Jaegeuk: replace BUG_ON with WARN_ON] Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
This commit is contained in:
parent
c0d39e65ba
commit
064e082328
@ -515,9 +515,12 @@ static inline void mutex_unlock_op(struct f2fs_sb_info *sbi, enum lock_type t)
|
|||||||
/*
|
/*
|
||||||
* Check whether the given nid is within node id range.
|
* Check whether the given nid is within node id range.
|
||||||
*/
|
*/
|
||||||
static inline void check_nid_range(struct f2fs_sb_info *sbi, nid_t nid)
|
static inline int check_nid_range(struct f2fs_sb_info *sbi, nid_t nid)
|
||||||
{
|
{
|
||||||
BUG_ON((nid >= NM_I(sbi)->max_nid));
|
WARN_ON((nid >= NM_I(sbi)->max_nid));
|
||||||
|
if (nid >= NM_I(sbi)->max_nid)
|
||||||
|
return -EINVAL;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define F2FS_DEFAULT_ALLOCATED_BLOCKS 1
|
#define F2FS_DEFAULT_ALLOCATED_BLOCKS 1
|
||||||
|
@ -44,7 +44,11 @@ static int do_read_inode(struct inode *inode)
|
|||||||
struct f2fs_inode *ri;
|
struct f2fs_inode *ri;
|
||||||
|
|
||||||
/* Check if ino is within scope */
|
/* Check if ino is within scope */
|
||||||
check_nid_range(sbi, inode->i_ino);
|
if (check_nid_range(sbi, inode->i_ino)) {
|
||||||
|
f2fs_msg(inode->i_sb, KERN_ERR, "bad inode number: %lu",
|
||||||
|
(unsigned long) inode->i_ino);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
node_page = get_node_page(sbi, inode->i_ino);
|
node_page = get_node_page(sbi, inode->i_ino);
|
||||||
if (IS_ERR(node_page))
|
if (IS_ERR(node_page))
|
||||||
|
Loading…
Reference in New Issue
Block a user