Re: [PATCH 15/16] of: unittest: initialize args before calling of_irq_parse_one()

From: Frank Rowand
Date: Fri Oct 05 2018 - 15:05:21 EST


On 10/05/18 06:26, Guenter Roeck wrote:
> On 10/04/2018 09:12 PM, frowand.list@xxxxxxxxx wrote:
>> From: Frank Rowand <frank.rowand@xxxxxxxx>
>>
>> Callers of of_irq_parse_one() blindly use the pointer args.np
>> without checking whether of_irq_parse_one() had an error and
>> thus did not set the value of args.np. Initialize args to
>> zero so that using the format "%pOF" to show the value of
>> args.np will show "(null)" when of_irq_parse_one() has an
>> error and does not set args.np instead of trying to
>> dereference a random value.
>>
>> Reported-by: Guenter Roeck <linux@xxxxxxxxxxxx>
>> Signed-off-by: Frank Rowand <frank.rowand@xxxxxxxx>
>
> Reviewed-by: Guenter Roeck <linux@xxxxxxxxxxxx>
>
> The same problem exists when of_parse_phandle_with_args() reports an error.

Thanks, I'll add a fix for that.

-Frank

>
> Guenter
>
>> ---
>> Â drivers/of/unittest.c | 5 +++--
>> Â 1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
>> index 6d80f474c8f2..b61a33f30a56 100644
>> --- a/drivers/of/unittest.c
>> +++ b/drivers/of/unittest.c
>> @@ -780,7 +780,7 @@ static void __init of_unittest_parse_interrupts(void)
>> ÂÂÂÂÂ for (i = 0; i < 4; i++) {
>> ÂÂÂÂÂÂÂÂÂ bool passed = true;
>> Â -ÂÂÂÂÂÂÂ args.args_count = 0;
>> +ÂÂÂÂÂÂÂ memset(&args, 0, sizeof(args));
>> ÂÂÂÂÂÂÂÂÂ rc = of_irq_parse_one(np, i, &args);
>> Â ÂÂÂÂÂÂÂÂÂ passed &= !rc;
>> @@ -801,7 +801,7 @@ static void __init of_unittest_parse_interrupts(void)
>> ÂÂÂÂÂ for (i = 0; i < 4; i++) {
>> ÂÂÂÂÂÂÂÂÂ bool passed = true;
>> Â -ÂÂÂÂÂÂÂ args.args_count = 0;
>> +ÂÂÂÂÂÂÂ memset(&args, 0, sizeof(args));
>> ÂÂÂÂÂÂÂÂÂ rc = of_irq_parse_one(np, i, &args);
>> Â ÂÂÂÂÂÂÂÂÂ /* Test the values from tests-phandle.dtsi */
>> @@ -854,6 +854,7 @@ static void __init of_unittest_parse_interrupts_extended(void)
>> ÂÂÂÂÂ for (i = 0; i < 7; i++) {
>> ÂÂÂÂÂÂÂÂÂ bool passed = true;
>> Â +ÂÂÂÂÂÂÂ memset(&args, 0, sizeof(args));
>> ÂÂÂÂÂÂÂÂÂ rc = of_irq_parse_one(np, i, &args);
>> Â ÂÂÂÂÂÂÂÂÂ /* Test the values from tests-phandle.dtsi */
>>
>
>