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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <dcb314@xxxxxxxxxxx>
Signed-off-by: Andrey Utkin <andrey.krieger.utkin@xxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux