From: Colin King <colin.king@canonical.com>
To: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Simon Sandström" <simon@nikanor.nu>,
devel@driverdev.osuosl.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] staging: kpc2000: fix integer overflow with left shifts
Date: Tue, 18 Jun 2019 10:15:54 +0000 [thread overview]
Message-ID: <20190618101554.31723-1-colin.king@canonical.com> (raw)
From: Colin Ian King <colin.king@canonical.com>
Currently there are several left shifts that are assigned to 64 bit
unsigned longs where a signed int 1 is being shifted, resulting in
an integer overflow. Fix this bit using the BIT_ULL macro to perform
a 64 bit shift. Also clean up an overly long statement.
Addresses-Coverity: ("Unintentional integer overflow")
Fixes: 7dc7967fc39a ("staging: kpc2000: add initial set of Daktronics drivers")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/staging/kpc2000/kpc2000/cell_probe.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index 138d16bcf6e1..c124a836db27 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -238,7 +238,7 @@ int kp2000_check_uio_irq(struct kp2000_device *pcard, u32 irq_num)
{
u64 interrupt_active = readq(pcard->sysinfo_regs_base + REG_INTERRUPT_ACTIVE);
u64 interrupt_mask_inv = ~readq(pcard->sysinfo_regs_base + REG_INTERRUPT_MASK);
- u64 irq_check_mask = (1 << irq_num);
+ u64 irq_check_mask = BIT_ULL(irq_num);
if (interrupt_active & irq_check_mask) { // if it's active (interrupt pending)
if (interrupt_mask_inv & irq_check_mask) { // and if it's not masked off
@@ -257,7 +257,9 @@ irqreturn_t kuio_handler(int irq, struct uio_info *uioinfo)
return IRQ_NONE;
if (kp2000_check_uio_irq(kudev->pcard, kudev->cte.irq_base_num)) {
- writeq((1 << kudev->cte.irq_base_num), kudev->pcard->sysinfo_regs_base + REG_INTERRUPT_ACTIVE); // Clear the active flag
+ /* Clear the active flag */
+ writeq(BIT_ULL(kudev->cte.irq_base_num),
+ kudev->pcard->sysinfo_regs_base + REG_INTERRUPT_ACTIVE);
return IRQ_HANDLED;
}
return IRQ_NONE;
@@ -273,9 +275,9 @@ int kuio_irqcontrol(struct uio_info *uioinfo, s32 irq_on)
mutex_lock(&pcard->sem);
mask = readq(pcard->sysinfo_regs_base + REG_INTERRUPT_MASK);
if (irq_on)
- mask &= ~(1 << (kudev->cte.irq_base_num));
+ mask &= ~(BIT_ULL(kudev->cte.irq_base_num));
else
- mask |= (1 << (kudev->cte.irq_base_num));
+ mask |= BIT_ULL(kudev->cte.irq_base_num);
writeq(mask, pcard->sysinfo_regs_base + REG_INTERRUPT_MASK);
mutex_unlock(&pcard->sem);
--
2.20.1
reply other threads:[~2019-06-18 10:15 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=20190618101554.31723-1-colin.king@canonical.com \
--to=colin.king@canonical.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=simon@nikanor.nu \
/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;
as well as URLs for NNTP newsgroup(s).