diff mbox

[5/8] drivers: ixgbevf: fix unsigned underflow

Message ID 1279219557-12525-1-git-send-email-segooon@gmail.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Kulikov Vasiliy July 15, 2010, 6:45 p.m. UTC
'count' is unsigned. It is initialized to zero, then it can be increased
multiple times, and finally it is used in such a way:

   >>>> count--;
   |
   |    /* clear timestamp and dma mappings for remaining portion of packet */
   |    while (count >= 0) {
   |            count--;
   |            ...
   ^
If count is zero here (so, it was never increased), we would have a very
long loop :)

Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
---
 drivers/net/ixgbevf/ixgbevf_main.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

Comments

Rose, Gregory V July 15, 2010, 6:52 p.m. UTC | #1
>-----Original Message-----
>From: Kulikov Vasiliy [mailto:segooon@gmail.com]
>Sent: Thursday, July 15, 2010 11:46 AM
>To: kernel-janitors@vger.kernel.org
>Cc: David S. Miller; Kirsher, Jeffrey T; Rose, Gregory V; Eric Dumazet;
>Joe Perches; netdev@vger.kernel.org
>Subject: [PATCH 5/8] drivers: ixgbevf: fix unsigned underflow
>
>'count' is unsigned. It is initialized to zero, then it can be increased
>multiple times, and finally it is used in such a way:
>
>   >>>> count--;
>   |
>   |    /* clear timestamp and dma mappings for remaining portion of
>packet */
>   |    while (count >= 0) {
>   |            count--;
>   |            ...
>   ^
>If count is zero here (so, it was never increased), we would have a very
>long loop :)
>
>Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
>---
> drivers/net/ixgbevf/ixgbevf_main.c |    3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
>diff --git a/drivers/net/ixgbevf/ixgbevf_main.c
>b/drivers/net/ixgbevf/ixgbevf_main.c
>index 73f1e75..af49135 100644
>--- a/drivers/net/ixgbevf/ixgbevf_main.c
>+++ b/drivers/net/ixgbevf/ixgbevf_main.c
>@@ -2935,7 +2935,8 @@ static int ixgbevf_tx_map(struct ixgbevf_adapter
>*adapter,
> 	struct ixgbevf_tx_buffer *tx_buffer_info;
> 	unsigned int len;
> 	unsigned int total = skb->len;
>-	unsigned int offset = 0, size, count = 0;
>+	unsigned int offset = 0, size;
>+	int count = 0;
> 	unsigned int nr_frags = skb_shinfo(skb)->nr_frags;
> 	unsigned int f;
> 	int i;
>--
>1.7.0.4

Acked By: Greg Rose <gregory.v.rose@intel.com>

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller July 16, 2010, 3:28 a.m. UTC | #2
From: "Rose, Gregory V" <gregory.v.rose@intel.com>
Date: Thu, 15 Jul 2010 11:52:54 -0700

>>-----Original Message-----
>>From: Kulikov Vasiliy [mailto:segooon@gmail.com]
>>Sent: Thursday, July 15, 2010 11:46 AM
>>To: kernel-janitors@vger.kernel.org
>>Cc: David S. Miller; Kirsher, Jeffrey T; Rose, Gregory V; Eric Dumazet;
>>Joe Perches; netdev@vger.kernel.org
>>Subject: [PATCH 5/8] drivers: ixgbevf: fix unsigned underflow
>>
>>'count' is unsigned. It is initialized to zero, then it can be increased
>>multiple times, and finally it is used in such a way:
>>
>>   >>>> count--;
>>   |
>>   |    /* clear timestamp and dma mappings for remaining portion of
>>packet */
>>   |    while (count >= 0) {
>>   |            count--;
>>   |            ...
>>   ^
>>If count is zero here (so, it was never increased), we would have a very
>>long loop :)
>>
>>Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
...
> Acked By: Greg Rose <gregory.v.rose@intel.com>

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

Patch

diff --git a/drivers/net/ixgbevf/ixgbevf_main.c b/drivers/net/ixgbevf/ixgbevf_main.c
index 73f1e75..af49135 100644
--- a/drivers/net/ixgbevf/ixgbevf_main.c
+++ b/drivers/net/ixgbevf/ixgbevf_main.c
@@ -2935,7 +2935,8 @@  static int ixgbevf_tx_map(struct ixgbevf_adapter *adapter,
 	struct ixgbevf_tx_buffer *tx_buffer_info;
 	unsigned int len;
 	unsigned int total = skb->len;
-	unsigned int offset = 0, size, count = 0;
+	unsigned int offset = 0, size;
+	int count = 0;
 	unsigned int nr_frags = skb_shinfo(skb)->nr_frags;
 	unsigned int f;
 	int i;