mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-03 17:14:14 +08:00
e0c1623357
There are several error handling bugs in mscc_ocelot_init_ports(). I
went through the code, and carefully audited it and made fixes and
cleanups.
1) The ocelot_probe_port() function didn't have a mirror release function
so it was hard to follow. I created the ocelot_release_port()
function.
2) In the ocelot_probe_port() function, if the register_netdev() call
failed, then it lead to a double free_netdev(dev) bug. Fix this by
setting "ocelot->ports[port] = NULL" on the error path.
3) I was concerned that the "port" which comes from of_property_read_u32()
might be out of bounds so I added a check for that.
4) In the original code if ocelot_regmap_init() failed then the driver
tried to continue but I think that should be a fatal error.
5) If ocelot_probe_port() failed then the most recent devlink was leaked.
The fix for mostly came Vladimir Oltean. Get rid of "registered_ports"
and just set a bit in "devlink_ports_registered" to say when the
devlink port has been registered (and needs to be unregistered on
error). There are fewer than 32 ports so a u32 is large enough for
this purpose.
6) The error handling if the final ocelot_port_devlink_init() failed had
two problems. The "while (port-- >= 0)" loop should have been
"--port" pre-op instead of a post-op to avoid a buffer underflow.
The "if (!registered_ports[port])" condition was reversed leading to
resource leaks and double frees.
Fixes:
|
||
---|---|---|
.. | ||
3com | ||
8390 | ||
adaptec | ||
aeroflex | ||
agere | ||
alacritech | ||
allwinner | ||
alteon | ||
altera | ||
amazon | ||
amd | ||
apm | ||
apple | ||
aquantia | ||
arc | ||
atheros | ||
broadcom | ||
brocade | ||
cadence | ||
calxeda | ||
cavium | ||
chelsio | ||
cirrus | ||
cisco | ||
cortina | ||
davicom | ||
dec | ||
dlink | ||
emulex | ||
ezchip | ||
faraday | ||
freescale | ||
fujitsu | ||
hisilicon | ||
huawei | ||
i825xx | ||
ibm | ||
intel | ||
marvell | ||
mediatek | ||
mellanox | ||
micrel | ||
microchip | ||
moxa | ||
mscc | ||
myricom | ||
natsemi | ||
neterion | ||
netronome | ||
ni | ||
nvidia | ||
nxp | ||
oki-semi | ||
packetengines | ||
pasemi | ||
pensando | ||
qlogic | ||
qualcomm | ||
rdc | ||
realtek | ||
renesas | ||
rocker | ||
samsung | ||
seeq | ||
sfc | ||
sgi | ||
silan | ||
sis | ||
smsc | ||
socionext | ||
stmicro | ||
sun | ||
synopsys | ||
tehuti | ||
ti | ||
toshiba | ||
tundra | ||
via | ||
wiznet | ||
xilinx | ||
xircom | ||
xscale | ||
dnet.c | ||
dnet.h | ||
ec_bhf.c | ||
ethoc.c | ||
fealnx.c | ||
jme.c | ||
jme.h | ||
Kconfig | ||
korina.c | ||
lantiq_etop.c | ||
lantiq_xrx200.c | ||
Makefile |