From: Tuo Li <islituo@gmail.com>
To: sathya.prakash@broadcom.com, sreekanth.reddy@broadcom.com,
suganath-prabu.subramani@broadcom.com, jejb@linux.ibm.com,
martin.petersen@oracle.com
Cc: MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org,
linux-kernel@vger.kernel.org, baijiaju1990@gmail.com,
Tuo Li <islituo@gmail.com>, TOTE Robot <oslab@tsinghua.edu.cn>
Subject: [PATCH] scsi: mpt3sas: Fix a possible divide-by-zero bug in base_mod64()
Date: Wed, 11 Aug 2021 06:24:39 -0700 [thread overview]
Message-ID: <20210811132439.10370-1-islituo@gmail.com> (raw)
The variable divisor is checked in:
if (!divisor)
This indicates that divisor can be NULL.
If so, a divide-by-zero bug will occur:
remainder = do_div(dividend, divisor);
To fix the possible bug, the function returns 0 when divisor is zero.
Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Tuo Li <islituo@gmail.com>
---
drivers/scsi/mpt3sas/mpt3sas_base.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c
index 19b1c0cf5f2a..3550998ea38b 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -1594,8 +1594,10 @@ static u32 base_mod64(u64 dividend, u32 divisor)
{
u32 remainder;
- if (!divisor)
+ if (!divisor) {
pr_err("mpt3sas: DIVISOR is zero, in div fn\n");
+ return 0;
+ }
remainder = do_div(dividend, divisor);
return remainder;
}
--
2.25.1
reply other threads:[~2021-08-11 13:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210811132439.10370-1-islituo@gmail.com \
--to=islituo@gmail.com \
--cc=MPT-FusionLinux.pdl@broadcom.com \
--cc=baijiaju1990@gmail.com \
--cc=jejb@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=oslab@tsinghua.edu.cn \
--cc=sathya.prakash@broadcom.com \
--cc=sreekanth.reddy@broadcom.com \
--cc=suganath-prabu.subramani@broadcom.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