Add a check for sb_blocksize before dividing.
Signed-off-by: Daniel Yang <danielyangkang@gmail.com>
Reported-by: syzbot+6a0633f11d3fb88860bf@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=6a0633f11d3fb88860bf
---
fs/qnx6/super_mmi.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/fs/qnx6/super_mmi.c b/fs/qnx6/super_mmi.c
index d282c2c73..57f34320b 100644
--- a/fs/qnx6/super_mmi.c
+++ b/fs/qnx6/super_mmi.c
@@ -65,8 +65,13 @@ struct qnx6_super_block *qnx6_mmi_fill_super(struct super_block *s, int silent)
}
/* calculate second superblock blocknumber */
+ __u32 sb1_blocksize = fs32_to_cpu(sbi, sb1->sb_blocksize);
+
+ if (!sb1_blocksize) {
+ pr_err("superblock #1 blocksize 0\n");
+ goto out;
+ }
offset = fs32_to_cpu(sbi, sb1->sb_num_blocks) + QNX6_SUPERBLOCK_AREA /
- fs32_to_cpu(sbi, sb1->sb_blocksize);
+ sb1_blocksize;
/* set new blocksize */
if (!sb_set_blocksize(s, fs32_to_cpu(sbi, sb1->sb_blocksize))) {
--
2.39.2