diff mbox series

[net-next] net: mvpp2: cls: Check RSS table index validity when creating a context

Message ID 20190527115201.12721-1-maxime.chevallier@bootlin.com
State Accepted
Delegated to: David Miller
Headers show
Series [net-next] net: mvpp2: cls: Check RSS table index validity when creating a context | expand

Commit Message

Maxime Chevallier May 27, 2019, 11:52 a.m. UTC
Make sure we don't use an out-of-bound index for the per-port RSS
context array.

As of today, the global context creation in mvpp22_rss_context_create
will prevent us from reaching this case, but we should still make sure
we are using a sane value anyway.

Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
---
 drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

David Miller May 28, 2019, 6:20 p.m. UTC | #1
From: Maxime Chevallier <maxime.chevallier@bootlin.com>
Date: Mon, 27 May 2019 13:52:01 +0200

> Make sure we don't use an out-of-bound index for the per-port RSS
> context array.
> 
> As of today, the global context creation in mvpp22_rss_context_create
> will prevent us from reaching this case, but we should still make sure
> we are using a sane value anyway.
> 
> Reported-by: kbuild test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>

Applied.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c
index cd0daad011ce..bd19a910dc90 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c
@@ -1466,6 +1466,9 @@  int mvpp22_port_rss_ctx_create(struct mvpp2_port *port, u32 *port_ctx)
 			break;
 	}
 
+	if (i == MVPP22_N_RSS_TABLES)
+		return -EINVAL;
+
 	port->rss_ctx[i] = rss_ctx;
 	*port_ctx = i;