aspeed-adc driver kpanic

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


On Mon, 4 Oct 2021 at 18:35, Patrick Williams <patrick at stwcx.xyz> wrote:
>
> Hi Billy,
>
> When I run the latest linux-5.14 on QEMU with the Witherspoon config, I end up
> with a kernel panic[1].  I think there is an ordering problem in the aspeed_adc
> driver.
>
> See [2,3].  The code registers with devm a pointer to the prescaler object which
> is not yet created.  I think it is possible that the struct value contains
> uninitialized data as well.  Can you please take a look at this?

I merged v6 of Billy's patches, but he sent a v7 version that
contained a fix this issue:

--- 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);


>
> 1. https://gist.github.com/williamspatrick/4a0f0d1e0ca6f54816461a8df09e6cb8
> 2. https://github.com/openbmc/linux/blob/dev-5.14/drivers/iio/adc/aspeed_adc.c#L513
> 3. https://github.com/openbmc/linux/blob/dev-5.14/drivers/iio/adc/aspeed_adc.c#L527
>
> --
> Patrick Williams


More information about the openbmc mailing list