qed: potential overflow in qed_cxt_src_t2_alloc()
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 7 Jun 2016 12:04:16 +0000 (15:04 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 8 Jun 2016 07:33:25 +0000 (00:33 -0700)
In the current code "ent_per_page" could be more than "conn_num" making
"conn_num" negative after the subtraction.  In the next iteration
through the loop then the negative is treated as a very high positive
meaning we don't put a limit on "ent_num".  It could lead to memory
corruption.

Fixes: dbb799c39717 ('qed: Initialize hardware for new protocols')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/qlogic/qed/qed_cxt.c

index d85b7ba8cb9acfcf94ac4ae413c1faaef0b3d6b5..1c35f376143e3f4d0e6605937423decacd277f2c 100644 (file)
@@ -850,7 +850,7 @@ static int qed_cxt_src_t2_alloc(struct qed_hwfn *p_hwfn)
                        val = 0;
                entries[j].next = cpu_to_be64(val);
 
-               conn_num -= ent_per_page;
+               conn_num -= ent_num;
        }
 
        return 0;