Re: [PATCH V2] soc/tegra: fuse: fix illegal free of IO base address

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Dec 30, 2018 at 05:58:08PM +0200, Timo Alho wrote:
> On cases where device tree entries for fuse and clock provider are in
> different order, fuse driver needs to defer probing. This leads to
> freeing incorrect IO base address as the fuse->base variable gets
> overwritten once during first probe invocation. This leads to
> following spew during boot:
> 
..
> 
> Fix this by retaining the value of fuse->base until driver has
> successfully probed.
> 

Maybe there should be a comment in the code on why this is needed
because it's not obvious to understand by just reading the code I think.

Peter.

> Signed-off-by: Timo Alho <talho@xxxxxxxxxx>
> ---
> V2: Addressed review comments from Jon. Which means essentially a rewrote of the patch.
> ---
>  drivers/soc/tegra/fuse/fuse-tegra.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/soc/tegra/fuse/fuse-tegra.c b/drivers/soc/tegra/fuse/fuse-tegra.c
> index a33ee8e..5162570 100644
> --- a/drivers/soc/tegra/fuse/fuse-tegra.c
> +++ b/drivers/soc/tegra/fuse/fuse-tegra.c
> @@ -137,13 +137,17 @@ static int tegra_fuse_probe(struct platform_device *pdev)
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	fuse->phys = res->start;
>  	fuse->base = devm_ioremap_resource(&pdev->dev, res);
> -	if (IS_ERR(fuse->base))
> -		return PTR_ERR(fuse->base);
> +	if (IS_ERR(fuse->base)) {
> +		err = PTR_ERR(fuse->base);
> +		fuse->base = base;
> +		return err;
> +	}
>  
>  	fuse->clk = devm_clk_get(&pdev->dev, "fuse");
>  	if (IS_ERR(fuse->clk)) {
>  		dev_err(&pdev->dev, "failed to get FUSE clock: %ld",
>  			PTR_ERR(fuse->clk));
> +		fuse->base = base;
>  		return PTR_ERR(fuse->clk);
>  	}
>  
> @@ -152,8 +156,10 @@ static int tegra_fuse_probe(struct platform_device *pdev)
>  
>  	if (fuse->soc->probe) {
>  		err = fuse->soc->probe(fuse);
> -		if (err < 0)
> +		if (err < 0) {
> +			fuse->base = base;
>  			return err;
> +		}
>  	}
>  
>  	if (tegra_fuse_create_sysfs(&pdev->dev, fuse->soc->info->size,
> -- 
> 2.7.4
> 



[Index of Archives]     [ARM Kernel]     [Linux ARM]     [Linux ARM MSM]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux