[PATCH] powerpc/kexec: Fix the return of uninitialized variable

zhangzekun (A) zhangzekun11 at huawei.com
Tue Oct 8 19:53:07 AEDT 2024


在 2024/9/30 17:01, Madhavan Srinivasan 写道:
> 
> 
> On 9/30/24 1:57 PM, Christophe Leroy wrote:
>>
>>
>> Le 30/09/2024 à 09:56, Zhang Zekun a écrit :
>>> [Vous ne recevez pas souvent de courriers de zhangzekun11 at huawei.com. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ]
>>>
>>> The of_property_read_u64() can fail and remain the variable uninitialized,
>>
>> Replace "remain" by "leave".
>>
>>> which will then be used. Return error if we failed to read the property.
>>
>> Rewrite to avoid "we".  For instance "Return error if reading the property failed"
>>
>>>
>>> Fixes: 2e6bd221d96f ("powerpc/kexec_file: Enable early kernel OPAL calls")
>>> Signed-off-by: Zhang Zekun <zhangzekun11 at huawei.com>
>>> ---
>>>    arch/powerpc/kexec/file_load_64.c | 9 +++++++--
>>>    1 file changed, 7 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c
>>> index 9738adabeb1f..dc65c1391157 100644
>>> --- a/arch/powerpc/kexec/file_load_64.c
>>> +++ b/arch/powerpc/kexec/file_load_64.c
>>> @@ -736,13 +736,18 @@ int setup_purgatory_ppc64(struct kimage *image, const void *slave_code,
>>>           if (dn) {
>>>                   u64 val;
> 
> Instead cant we init val as -1 ??
> Why to add check?
> 

Hi, Madhavan,

I am not sure when the default value -1 will be checked, and it would be 
more obvious to me to add check when reading property failed. Besides, 
in arch/powerpc, checking the return val when of_property_read_u64() 
failed seems to be a more common way.

Best Regards,
Zekun


More information about the Linuxppc-dev mailing list