From: Roman Smirnov <r.smirnov@omp.ru>
To: <linux-kernel@vger.kernel.org>
Cc: Roman Smirnov <r.smirnov@omp.ru>,
Sergey Shtylyov <s.shtylyov@omp.ru>,
<lvc-project@linuxtesting.org>
Subject: [PATCH] fixp-arith: prevent division by zero in fixp_sin32_rad()
Date: Tue, 12 Mar 2024 12:48:52 +0300 [thread overview]
Message-ID: <20240312094852.15400-1-r.smirnov@omp.ru> (raw)
The parameter twopi can have a zero value. It is necessary
to prevent division by zero.
Found by Linux Verification Center (linuxtesting.org) with Svace.
Signed-off-by: Roman Smirnov <r.smirnov@omp.ru>
---
include/linux/fixp-arith.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/linux/fixp-arith.h b/include/linux/fixp-arith.h
index e485fb0c1201..434eee8bd9ef 100644
--- a/include/linux/fixp-arith.h
+++ b/include/linux/fixp-arith.h
@@ -118,8 +118,9 @@ static inline s32 fixp_sin32_rad(u32 radians, u32 twopi)
/*
* Avoid too large values for twopi, as we don't want overflows.
+ * Also prevent division by zero.
*/
- BUG_ON(twopi > 1 << 18);
+ BUG_ON(!twopi || twopi > 1 << 18);
degrees = (radians * 360) / twopi;
tmp = radians - (degrees * twopi) / 360;
--
2.34.1
next reply other threads:[~2024-03-12 9:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-12 9:48 Roman Smirnov [this message]
2024-03-13 18:23 ` Sergey Shtylyov
2026-01-31 19:26 ` Sergey Shtylyov
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=20240312094852.15400-1-r.smirnov@omp.ru \
--to=r.smirnov@omp.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=s.shtylyov@omp.ru \
/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
all inboxes | Powered by JetHome®