Commit 48c77bdf authored by Volodymyr Mytnyk's avatar Volodymyr Mytnyk Committed by David S. Miller

net: prestera: acl: fix 'client_map' buff overflow

smatch warnings:
drivers/net/ethernet/marvell/prestera/prestera_acl.c:103
prestera_acl_chain_to_client() error: buffer overflow
'client_map' 3 <= 3

	prestera_acl_chain_to_client(u32 chain_index, ...)
        ...
	u32 client_map[] = {
		PRESTERA_HW_COUNTER_CLIENT_LOOKUP_0,
		PRESTERA_HW_COUNTER_CLIENT_LOOKUP_1,
		PRESTERA_HW_COUNTER_CLIENT_LOOKUP_2
	};
	if (chain_index > ARRAY_SIZE(client_map))
	...

Fixes: fa5d824c ("net: prestera: acl: add multi-chain support offload")
Reported-by: default avatarkernel test robot <lkp@intel.com>
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarVolodymyr Mytnyk <vmytnyk@marvell.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 173a272a
...@@ -97,7 +97,7 @@ int prestera_acl_chain_to_client(u32 chain_index, u32 *client) ...@@ -97,7 +97,7 @@ int prestera_acl_chain_to_client(u32 chain_index, u32 *client)
PRESTERA_HW_COUNTER_CLIENT_LOOKUP_2 PRESTERA_HW_COUNTER_CLIENT_LOOKUP_2
}; };
if (chain_index > ARRAY_SIZE(client_map)) if (chain_index >= ARRAY_SIZE(client_map))
return -EINVAL; return -EINVAL;
*client = client_map[chain_index]; *client = client_map[chain_index];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment