summaryrefslogtreecommitdiffstats
path: root/drivers/bus
diff options
context:
space:
mode:
authorQinglang Miao <miaoqinglang@huawei.com>2020-11-20 15:48:47 +0800
committerThomas Bogendoerfer <tsbogend@alpha.franken.de>2020-11-27 10:38:02 +0100
commitf0e82242b16826077a2775eacfe201d803bb7a22 (patch)
tree5eb27f4138706261304b4af66192a97ee1764783 /drivers/bus
parenta307a4ce9ecd2e23c71318201330d9d648b3f818 (diff)
downloadlinux-f0e82242b16826077a2775eacfe201d803bb7a22.tar.bz2
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/ Fixes: 8286ae03308c ("MIPS: Add CDMM bus support") Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com> Acked-by: Serge Semin <fancer.lancer@gmail.com> Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Diffstat (limited to 'drivers/bus')
-rw-r--r--drivers/bus/mips_cdmm.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/bus/mips_cdmm.c b/drivers/bus/mips_cdmm.c
index 9f7ed1fcd428..626dedd110cb 100644
--- a/drivers/bus/mips_cdmm.c
+++ b/drivers/bus/mips_cdmm.c
@@ -559,10 +559,8 @@ static void mips_cdmm_bus_discover(struct mips_cdmm_bus *bus)
dev_set_name(&dev->dev, "cdmm%u-%u", cpu, id);
++id;
ret = device_register(&dev->dev);
- if (ret) {
+ if (ret)
put_device(&dev->dev);
- kfree(dev);
- }
}
}