2014-07-17 12:15:40

by Andrey Utkin

[permalink] [raw]
Subject: [PATCH 3/3] drivers/crypto/omap-{des,aes}.c: fix sanity checks

Unsigned variable "total" was tested for negativity after subtraction
operation. 2 instances.
Replaced that with the test of minuend being greater than subtrahend
before the subtraction.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=80421
Reported-by: David Binderman <[email protected]>
Signed-off-by: Andrey Utkin <[email protected]>
---
drivers/crypto/omap-aes.c | 4 ++--
drivers/crypto/omap-des.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c
index cb98fa5..413ed78 100644
--- a/drivers/crypto/omap-aes.c
+++ b/drivers/crypto/omap-aes.c
@@ -1038,10 +1038,10 @@ static irqreturn_t omap_aes_irq(int irq, void *dev_id)
}
}

+ BUG_ON(dd->total < AES_BLOCK_SIZE);
+
dd->total -= AES_BLOCK_SIZE;

- BUG_ON(dd->total < 0);
-
/* Clear IRQ status */
status &= ~AES_REG_IRQ_DATA_OUT;
omap_aes_write(dd, AES_REG_IRQ_STATUS(dd), status);
diff --git a/drivers/crypto/omap-des.c b/drivers/crypto/omap-des.c
index b8bc84b..93aa213 100644
--- a/drivers/crypto/omap-des.c
+++ b/drivers/crypto/omap-des.c
@@ -965,10 +965,10 @@ static irqreturn_t omap_des_irq(int irq, void *dev_id)
}
}

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

- BUG_ON(dd->total < 0);
-
/* Clear IRQ status */
status &= ~DES_REG_IRQ_DATA_OUT;
omap_des_write(dd, DES_REG_IRQ_STATUS(dd), status);
--
1.8.5.5