6lowpan: iphc: Fix an off-by-one check of array index
authorColin Ian King <colin.king@canonical.com>
Mon, 12 Jul 2021 12:14:40 +0000 (13:14 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 15 Sep 2021 07:50:34 +0000 (09:50 +0200)
commitc7ebd3622bf843108809c147270e838ec85dfd90
tree0d05505cd7b0f5df4449f025b996030558783f05
parentdef6efdf91e72c04d5b12158a6a9cfc46bba8573
6lowpan: iphc: Fix an off-by-one check of array index

[ Upstream commit 9af417610b6142e826fd1ee8ba7ff3e9a2133a5a ]

The bounds check of id is off-by-one and the comparison should
be >= rather >. Currently the WARN_ON_ONCE check does not stop
the out of range indexing of &ldev->ctx.table[id] so also add
a return path if the bounds are out of range.

Addresses-Coverity: ("Illegal address computation").
Fixes: 5609c185f24d ("6lowpan: iphc: add support for stateful compression")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/6lowpan/debugfs.c