OSDN Git Service

net: arc_emac: Fix use after free in arc_mdio_probe()
authorJianglei Nie <niejianglei2021@163.com>
Wed, 9 Mar 2022 12:18:24 +0000 (20:18 +0800)
committerJakub Kicinski <kuba@kernel.org>
Thu, 10 Mar 2022 22:49:21 +0000 (14:49 -0800)
commitbc0e610a6eb0d46e4123fafdbe5e6141d9fff3be
treef8bc90a5e30554f524a5e1853461d62555c7d9fc
parent633593a808980f82d251d0ca89730d8bb8b0220c
net: arc_emac: Fix use after free in arc_mdio_probe()

If bus->state is equal to MDIOBUS_ALLOCATED, mdiobus_free(bus) will free
the "bus". But bus->name is still used in the next line, which will lead
to a use after free.

We can fix it by putting the name in a local variable and make the
bus->name point to the rodata section "name",then use the name in the
error message without referring to bus to avoid the uaf.

Fixes: 95b5fc03c189 ("net: arc_emac: Make use of the helper function dev_err_probe()")
Signed-off-by: Jianglei Nie <niejianglei2021@163.com>
Link: https://lore.kernel.org/r/20220309121824.36529-1-niejianglei2021@163.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/arc/emac_mdio.c