Commit d326d99a authored by Colin Ian King's avatar Colin Ian King Committed by Greg Kroah-Hartman

staging: kpc2000: fix integer overflow with left shifts

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: 7dc7967f ("staging: kpc2000: add initial set of Daktronics drivers")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a50185cb
...@@ -238,7 +238,7 @@ int kp2000_check_uio_irq(struct kp2000_device *pcard, u32 irq_num) ...@@ -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_active = readq(pcard->sysinfo_regs_base + REG_INTERRUPT_ACTIVE);
u64 interrupt_mask_inv = ~readq(pcard->sysinfo_regs_base + REG_INTERRUPT_MASK); 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_active & irq_check_mask) { // if it's active (interrupt pending)
if (interrupt_mask_inv & irq_check_mask) { // and if it's not masked off 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) ...@@ -257,7 +257,9 @@ irqreturn_t kuio_handler(int irq, struct uio_info *uioinfo)
return IRQ_NONE; return IRQ_NONE;
if (kp2000_check_uio_irq(kudev->pcard, kudev->cte.irq_base_num)) { 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_HANDLED;
} }
return IRQ_NONE; return IRQ_NONE;
...@@ -273,9 +275,9 @@ int kuio_irqcontrol(struct uio_info *uioinfo, s32 irq_on) ...@@ -273,9 +275,9 @@ int kuio_irqcontrol(struct uio_info *uioinfo, s32 irq_on)
mutex_lock(&pcard->sem); mutex_lock(&pcard->sem);
mask = readq(pcard->sysinfo_regs_base + REG_INTERRUPT_MASK); mask = readq(pcard->sysinfo_regs_base + REG_INTERRUPT_MASK);
if (irq_on) if (irq_on)
mask &= ~(1 << (kudev->cte.irq_base_num)); mask &= ~(BIT_ULL(kudev->cte.irq_base_num));
else 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); writeq(mask, pcard->sysinfo_regs_base + REG_INTERRUPT_MASK);
mutex_unlock(&pcard->sem); mutex_unlock(&pcard->sem);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment