diff options
author | Qinglang Miao <miaoqinglang@huawei.com> | 2020-11-20 10:48:47 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-12-30 13:25:57 +0300 |
commit | 84f341fa31faf4233a283d46fe4f6dc9b3026539 (patch) | |
tree | 06b002319d77c8e39ea243db6bd71012f388c3a8 | |
parent | 5f73062a69ecd13eb1940c990958123e9e186309 (diff) | |
download | linux-84f341fa31faf4233a283d46fe4f6dc9b3026539.tar.xz |
mips: cdmm: fix use-after-free in mips_cdmm_bus_discover
[ Upstream commit f0e82242b16826077a2775eacfe201d803bb7a22 ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | drivers/bus/mips_cdmm.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/bus/mips_cdmm.c b/drivers/bus/mips_cdmm.c index 1b14256376d2..7c1da45be166 100644 --- a/drivers/bus/mips_cdmm.c +++ b/drivers/bus/mips_cdmm.c @@ -544,10 +544,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); - } } } |