[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220607155233.27235-1-xiaohuizhang@ruc.edu.cn>
Date: Tue, 7 Jun 2022 23:52:33 +0800
From: Xiaohui Zhang <xiaohuizhang@....edu.cn>
To: Xiaohui Zhang <xiaohuizhang@....edu.cn>,
Mark Brown <broonie@...nel.org>, linux-spi@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH 1/1] spi: fix use after free in of_spi_notify
We can't use "ctlr->dev" after it has been freed.
Signed-off-by: Xiaohui Zhang <xiaohuizhang@....edu.cn>
---
drivers/spi/spi.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index b9e2c7e7c580..dadfcdc6c38f 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -4198,14 +4198,15 @@ static int of_spi_notify(struct notifier_block *nb, unsigned long action,
}
spi = of_register_spi_device(ctlr, rd->dn);
- put_device(&ctlr->dev);
if (IS_ERR(spi)) {
pr_err("%s: failed to create for '%pOF'\n",
__func__, rd->dn);
+ put_device(&ctlr->dev);
of_node_clear_flag(rd->dn, OF_POPULATED);
return notifier_from_errno(PTR_ERR(spi));
}
+ put_device(&ctlr->dev);
break;
case OF_RECONFIG_CHANGE_REMOVE:
--
2.17.1
Powered by blists - more mailing lists