Skip to content

Commit c84f6ce

Browse files
vladimirolteankuba-moo
authored andcommitted
net: dsa: mv88e6xxx: avoid unregistering devlink regions which were never registered
Russell King reports that a system with mv88e6xxx dereferences a NULL pointer when unbinding this driver: https://lore.kernel.org/netdev/[email protected]/ The crash seems to be in devlink_region_destroy(), which is not NULL tolerant but is given a NULL devlink global region pointer. At least on some chips, some devlink regions are conditionally registered since the blamed commit, see mv88e6xxx_setup_devlink_regions_global(): if (cond && !cond(chip)) continue; These are MV88E6XXX_REGION_STU and MV88E6XXX_REGION_PVT. If the chip does not have an STU or PVT, it should crash like this. To fix the issue, avoid unregistering those regions which are NULL, i.e. were skipped at mv88e6xxx_setup_devlink_regions_global() time. Fixes: 836021a ("net: dsa: mv88e6xxx: Export cross-chip PVT as devlink region") Tested-by: Russell King (Oracle) <[email protected]> Signed-off-by: Vladimir Oltean <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent b272732 commit c84f6ce

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/net/dsa/mv88e6xxx/devlink.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,8 @@ void mv88e6xxx_teardown_devlink_regions_global(struct dsa_switch *ds)
736736
int i;
737737

738738
for (i = 0; i < ARRAY_SIZE(mv88e6xxx_regions); i++)
739-
dsa_devlink_region_destroy(chip->regions[i]);
739+
if (chip->regions[i])
740+
dsa_devlink_region_destroy(chip->regions[i]);
740741
}
741742

742743
void mv88e6xxx_teardown_devlink_regions_port(struct dsa_switch *ds, int port)

0 commit comments

Comments
 (0)