Re: [PATCH] leds: leds-wm831x-status: init chip_pdata before access

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

 



Hi!

> wm831x_status_probe() accesses status from chip_pdata before
> initializing it. Fix it.
> 
> Signed-off-by: Shuah Khan <skhan@xxxxxxxxxxxxxxxxxxx>

Does it? ARRAY_SIZE() will be compile-time constant, no?

What is the bug? Did you test the code?

Best regards,
								Pavel


> +++ b/drivers/leds/leds-wm831x-status.c
> @@ -212,7 +212,7 @@ static int wm831x_status_probe(struct platform_device *pdev)
>  	struct wm831x_status_pdata pdata;
>  	struct wm831x_status *drvdata;
>  	struct resource *res;
> -	int id = pdev->id % ARRAY_SIZE(chip_pdata->status);
> +	int id;
>  	int ret;
>  
>  	res = platform_get_resource(pdev, IORESOURCE_REG, 0);
> @@ -229,9 +229,10 @@ static int wm831x_status_probe(struct platform_device *pdev)
>  	drvdata->wm831x = wm831x;
>  	drvdata->reg = res->start;
>  
> -	if (dev_get_platdata(wm831x->dev))
> +	if (dev_get_platdata(wm831x->dev)) {
>  		chip_pdata = dev_get_platdata(wm831x->dev);
> -	else
> +		id = pdev->id % ARRAY_SIZE(chip_pdata->status);
> +	} else
>  		chip_pdata = NULL;
>  
>  	memset(&pdata, 0, sizeof(pdata));

-- 
People of Russia, stop Putin before his war on Ukraine escalates.

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux