blob: 0f908e589ce1caba88caa0a6c41b7aec42b53af1 [file] [log] [blame]
From 3d8e4b5a5acafd3c44ad81ba104a12bfd7eab939 Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Tue, 18 Jun 2019 11:15:54 +0100
Subject: [PATCH] staging: kpc2000: fix integer overflow with left shifts
commit d326d99aa00f284e4320aededb3f7c663f5b4c87 upstream.
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index d6b57f550876..a343d3cd1b71 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -214,7 +214,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
return 1;
@@ -229,9 +229,11 @@ irqreturn_t kuio_handler(int irq, struct uio_info *uioinfo)
struct kpc_uio_device *kudev = uioinfo->priv;
if (irq != kudev->pcard->pdev->irq)
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
+
+ if (kp2000_check_uio_irq(kudev->pcard, kudev->cte.irq_base_num)) {
+ /* 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;
@@ -247,9 +249,9 @@ int kuio_irqcontrol(struct uio_info *uioinfo, s32 irq_on)
lock_card(pcard);
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);
unlock_card(pcard);
--
2.7.4