mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fix: divide error in qnx6_mmi_fill_super
@ 2024-11-04  5:44 Daniel Yang
  0 siblings, 0 replies; only message in thread
From: Daniel Yang @ 2024-11-04  5:44 UTC (permalink / raw)
  To: GitAuthor: Daniel Yang, open list; +Cc: syzbot+6a0633f11d3fb88860bf

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-11-04  5:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-04  5:44 [PATCH] fix: divide error in qnx6_mmi_fill_super Daniel Yang

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®