net: mvpp2: Fix parser entry init boundary check
authorMaxime Chevallier <maxime.chevallier@bootlin.com>
Thu, 5 Apr 2018 09:55:48 +0000 (11:55 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 6 Apr 2018 02:13:16 +0000 (22:13 -0400)
Boundary check in mvpp2_prs_init_from_hw must be done according to the
passed "tid" parameter, not the mvpp2_prs_entry index, which is not yet
initialized at the time of the check.

Fixes: 47e0e14eb1a6 ("net: mvpp2: Make mvpp2_prs_hw_read a parser entry init function")
Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/marvell/mvpp2.c

index 7fc1bbf51c44452380d6ff19d3f9843df5e5027e..54a038943c0649f74f72c8bdb5120d9c285ce8d2 100644 (file)
@@ -1604,7 +1604,7 @@ static int mvpp2_prs_init_from_hw(struct mvpp2 *priv,
 {
        int i;
 
-       if (pe->index > MVPP2_PRS_TCAM_SRAM_SIZE - 1)
+       if (tid > MVPP2_PRS_TCAM_SRAM_SIZE - 1)
                return -EINVAL;
 
        memset(pe, 0, sizeof(*pe));