Skip to content

Commit

Permalink
net: dsa: sja1105: fix buffer overflow in sja1105_setup_devlink_regio…
Browse files Browse the repository at this point in the history
…ns()

If an error occurs in dsa_devlink_region_create(), then 'priv->regions'
array will be accessed by negative index '-1'.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Rustam Subkhankulov <subkhankulov@ispras.ru>
Fixes: bf425b8 ("net: dsa: sja1105: expose static config as devlink region")
Link: https://lore.kernel.org/r/20220817003845.389644-1-subkhankulov@ispras.ru
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
RustamSubkhankulov authored and kuba-moo committed Aug 18, 2022
1 parent bec13ba commit fd8e899
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/dsa/sja1105/sja1105_devlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ static int sja1105_setup_devlink_regions(struct dsa_switch *ds)

region = dsa_devlink_region_create(ds, ops, 1, size);
if (IS_ERR(region)) {
while (i-- >= 0)
while (--i >= 0)
dsa_devlink_region_destroy(priv->regions[i]);
return PTR_ERR(region);
}
Expand Down

0 comments on commit fd8e899

Please sign in to comment.