[PATCH linux dev-5.14] iio: aspeed_adc: Fix prescaler devres cleanup

Joel Stanley joel at jms.id.au
Tue Oct 5 11:00:26 AEDT 2021


A devres hook is added for aspeed_adc_unregister_fixed_divider that
should pass a pointer to the fixed divider. It mistakenly had a pointer
to a different clock, leading to a null pointer dereference.

This change was included in v7 of the patches submitted upstream.

Fixes: ec35bd77c642 ("iio: adc: aspeed: Fix the calculate error of clock.")
Signed-off-by: Joel Stanley <joel at jms.id.au>
---
 drivers/iio/adc/aspeed_adc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/adc/aspeed_adc.c b/drivers/iio/adc/aspeed_adc.c
index d4d8ac07d40d..3e9850a43372 100644
--- a/drivers/iio/adc/aspeed_adc.c
+++ b/drivers/iio/adc/aspeed_adc.c
@@ -492,8 +492,8 @@ static int aspeed_adc_probe(struct platform_device *pdev)
 
 	data = iio_priv(indio_dev);
 	data->dev = &pdev->dev;
-	data->model_data = of_device_get_match_data(&pdev->dev);
 	platform_set_drvdata(pdev, indio_dev);
+	data->model_data = of_device_get_match_data(&pdev->dev);
 
 	data->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(data->base))
@@ -512,7 +512,7 @@ static int aspeed_adc_probe(struct platform_device *pdev)
 
 	ret = devm_add_action_or_reset(data->dev,
 				       aspeed_adc_unregister_fixed_divider,
-				       data->clk_prescaler);
+				       data->fixed_div_clk);
 	if (ret)
 		return ret;
 	snprintf(clk_parent_name, ARRAY_SIZE(clk_parent_name), clk_name);
-- 
2.33.0



More information about the openbmc mailing list