[PATCH] mips: cdmm: fix use-after-free in mips_cdmm_bus_discover

From: Qinglang Miao
Date: Fri Nov 20 2020 - 02:44:51 EST


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@xxxxxxxxxx>
Signed-off-by: Qinglang Miao <miaoqinglang@xxxxxxxxxx>
---
drivers/bus/mips_cdmm.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/bus/mips_cdmm.c b/drivers/bus/mips_cdmm.c
index 9f7ed1fcd..e43786c67 100644
--- a/drivers/bus/mips_cdmm.c
+++ b/drivers/bus/mips_cdmm.c
@@ -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);
}
}
}
--
2.23.0