[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240126061153.2883199-1-vamshigajjela@google.com>
Date: Fri, 26 Jan 2024 11:41:53 +0530
From: Vamshi Gajjela <vamshigajjela@...gle.com>
To: Mauro Carvalho Chehab <mchehab+huawei@...nel.org>, Stephen Boyd <sboyd@...nel.org>,
Johan Hovold <johan+linaro@...nel.org>
Cc: Caleb Connolly <caleb.connolly@...aro.org>, linux-kernel@...r.kernel.org,
manugautam@...gle.com, Vamshi Gajjela <vamshigajjela@...gle.com>
Subject: [PATCH v1 RESEND] spmi: hisi-spmi-controller: Fix kernel panic on rmmod
Ensure consistency in spmi_controller pointers between
spmi_controller_remove/put and driver spmi_del_controller functions.
The former requires a pointer to struct spmi_controller, while the
latter passes a pointer of struct spmi_controller_dev, leading to a
"Null pointer exception".
'nr' member of struct spmi_controller, which serves as an identifier
for the controller/bus. This value is assigned a dynamic ID in
spmi_controller_alloc, and overriding it from the driver results in an
ida_free error "ida_free called for id=xx which is not allocated".
Signed-off-by: Vamshi Gajjela <vamshigajjela@...gle.com>
---
drivers/spmi/hisi-spmi-controller.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/spmi/hisi-spmi-controller.c b/drivers/spmi/hisi-spmi-controller.c
index 9cbd473487cb..af51ffe24072 100644
--- a/drivers/spmi/hisi-spmi-controller.c
+++ b/drivers/spmi/hisi-spmi-controller.c
@@ -303,7 +303,6 @@ static int spmi_controller_probe(struct platform_device *pdev)
spin_lock_init(&spmi_controller->lock);
- ctrl->nr = spmi_controller->channel;
ctrl->dev.parent = pdev->dev.parent;
ctrl->dev.of_node = of_node_get(pdev->dev.of_node);
@@ -326,7 +325,8 @@ static int spmi_controller_probe(struct platform_device *pdev)
static void spmi_del_controller(struct platform_device *pdev)
{
- struct spmi_controller *ctrl = platform_get_drvdata(pdev);
+ struct spmi_controller_dev *spmi_controller = platform_get_drvdata(pdev);
+ struct spmi_controller *ctrl = spmi_controller->controller;
spmi_controller_remove(ctrl);
spmi_controller_put(ctrl);
--
2.43.0.472.g3155946c3a-goog
Powered by blists - more mailing lists