Skip to content

Commit

Permalink
crypto: omap-des - fix BUG_ON condition
Browse files Browse the repository at this point in the history
dd->total is unsigned so it won't do any good to check for negative
value after subtracting instead of that we should check if the
subtracted value is bigger than him

This was partially found by using a static code analysis program
called cppcheck.

Signed-off-by: Asaf Vertz <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
Asaf Vertz authored and herbertx committed Jan 8, 2015
1 parent 28c29f5 commit 42d2e78
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/crypto/omap-des.c
Original file line number Diff line number Diff line change
Expand Up @@ -965,9 +965,9 @@ static irqreturn_t omap_des_irq(int irq, void *dev_id)
}
}

dd->total -= DES_BLOCK_SIZE;
BUG_ON(dd->total < DES_BLOCK_SIZE);

BUG_ON(dd->total < 0);
dd->total -= DES_BLOCK_SIZE;

/* Clear IRQ status */
status &= ~DES_REG_IRQ_DATA_OUT;
Expand Down

0 comments on commit 42d2e78

Please sign in to comment.