Re: [PATCH 1/4] regulator/wm831x-dcdc: fix potential NULL dereference

From: Axel Lin
Date: Fri Aug 20 2010 - 11:44:19 EST


2010/8/20 Mark Brown <broonie@xxxxxxxxxxxxxxxxxxxxxxxxxxx>:
> On 20 Aug 2010, at 02:58, Axel Lin <axel.lin@xxxxxxxxx> wrote:
>
>> pdata is dereferenced earlier than tested for being NULL.
>> Thus move the dereference of "pdata" below the check for NULL.
>>
>> Signed-off-by: Axel Lin <axel.lin@xxxxxxxxx>
>> ---
>> drivers/regulator/wm831x-dcdc.c |   36 ++++++++++++++++++++++++------------
>> 1 files changed, 24 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c
>> index dbfaf59..ed66fac 100644
>> --- a/drivers/regulator/wm831x-dcdc.c
>> +++ b/drivers/regulator/wm831x-dcdc.c
>> @@ -501,14 +501,17 @@ static __devinit int wm831x_buckv_probe(struct platform_device *pdev)
>> {
>>       struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
>>       struct wm831x_pdata *pdata = wm831x->dev->platform_data;
>> -     int id = pdev->id % ARRAY_SIZE(pdata->dcdc);
>
> ARRAY_SIZE() isn't actually a dereference, it's evaluated at compile time.
Ah. You are right! Thanks.
Axel
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/