net: dsa: sja1105: fix buffer overflow in sja1105_setup_devlink_regions()
commitfd8e899cdb
upstream. 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:bf425b8205
("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
caa80c1f83
commit
e84c6321f3
@ -93,7 +93,7 @@ static int sja1105_setup_devlink_regions(struct dsa_switch *ds)
|
|||||||
|
|
||||||
region = dsa_devlink_region_create(ds, ops, 1, size);
|
region = dsa_devlink_region_create(ds, ops, 1, size);
|
||||||
if (IS_ERR(region)) {
|
if (IS_ERR(region)) {
|
||||||
while (i-- >= 0)
|
while (--i >= 0)
|
||||||
dsa_devlink_region_destroy(priv->regions[i]);
|
dsa_devlink_region_destroy(priv->regions[i]);
|
||||||
return PTR_ERR(region);
|
return PTR_ERR(region);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user