Skip to content

Commit c7ebd36

Browse files
Colin Ian Kinggregkh
authored andcommitted
6lowpan: iphc: Fix an off-by-one check of array index
[ Upstream commit 9af4176 ] 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: 5609c18 ("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>
1 parent def6efd commit c7ebd36

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎net/6lowpan/debugfs.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ static void lowpan_dev_debugfs_ctx_init(struct net_device *dev,
170170
struct dentry *root;
171171
char buf[32];
172172

173-
WARN_ON_ONCE(id > LOWPAN_IPHC_CTX_TABLE_SIZE);
173+
if (WARN_ON_ONCE(id >= LOWPAN_IPHC_CTX_TABLE_SIZE))
174+
return;
174175

175176
sprintf(buf, "%d", id);
176177

0 commit comments

Comments
 (0)