mips: cdmm: fix use-after-free in mips_cdmm_bus_discover
Subsystems (2)
PATCH 1/1 mips: cdmm: fix use-after-free in mips_cdmm_bus_discover
kfree(dev) has been called inside put_device so anther kfree would cause a use-after-free bug/
--- drivers/bus/mips_cdmm.c | 1 - 1 file changed, 1 deletion(-)
drivers/bus/mips_cdmm.c +0 -1
@@ -561,7 +561,6 @@ static void mips_cdmm_bus_discover(struct mips_cdmm_bus *bus) ret =device_register (&dev->dev);if (ret) {put_device (&dev->dev); -kfree (dev); } } }
Signature · 1 line
2.23.0
Hello Qinglang
Thanks for the patch. Good catch. Please see a tiny nitpick below.
Quoted 15 lines · Qinglang Miao
kfree(dev) has been called inside
put_deviceso anther kfree would cause a use-after-free bug/Fixes 8286ae03308c ("MIPS: Add CDMM bus support")Reported-by Hulk Robot <[email protected]>Signed-off-by Qinglang Miao <[email protected]>--- drivers/bus/mips_cdmm.c | 1 - 1 file changed, 1 deletion(-)drivers/bus/mips_cdmm.c +0
-0
drivers/bus/mips_cdmm.c static void mips_cdmm_bus_discover(struct mips_cdmm_bus *bus) · line 565
Quoted 6 lines
drivers/bus/mips_cdmm.c +0
-1@@ -561,7 +561,6 @@ static void mips_cdmm_bus_discover(struct mips_cdmm_bus *bus) ret =device_register (&dev->dev);if (ret) {put_device (&dev->dev); -kfree (dev); }
After removing kfree() from here the braces around the if clause are no more needed in accordance with the kernel coding style. Please remove them too. Then feel free to add the tag
-Sergey
Quoted 5 lines
drivers/bus/mips_cdmm.c +0
-0}}
Signature · 1 line
2.23.0
Thomas Bogendoerfer
maintainerQuoted 9 lines · Qinglang Miao
kfree(dev) has been called inside
put_deviceso anther kfree would cause a use-after-free bug/Fixes 8286ae03308c ("MIPS: Add CDMM bus support")Reported-by Hulk Robot <[email protected]>Signed-off-by Qinglang Miao <[email protected]>--- drivers/bus/mips_cdmm.c | 1 - 1 file changed, 1 deletion(-)
applied with braces removal to mips-next.
Thomas.
Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]