From: Madhavan Srinivasan <maddy@linux.ibm.com>
To: Christophe Leroy <christophe.leroy@csgroup.eu>,
Zhang Zekun <zhangzekun11@huawei.com>,
mpe@ellerman.id.au, npiggin@gmail.com, naveen@kernel.org,
linuxppc-dev@lists.ozlabs.org
Cc: chenjun102@huawei.com
Subject: Re: [PATCH] powerpc/kexec: Fix the return of uninitialized variable
Date: Mon, 30 Sep 2024 14:31:51 +0530 [thread overview]
Message-ID: <67db60e6-8f61-4907-8a7c-93cd0d4cb034@linux.ibm.com> (raw)
In-Reply-To: <37ee3c12-8a88-45ca-a70b-72af504e0d2b@csgroup.eu>
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@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@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?
>>
>> - of_property_read_u64(dn, "opal-base-address", &val);
>> + ret = of_property_read_u64(dn, "opal-base-address", &val);
>> + if (ret)
>> + goto out;
>> +
>> ret = kexec_purgatory_get_set_symbol(image, "opal_base", &val,
>> sizeof(val), false);
>> if (ret)
>> goto out;
>>
>> - of_property_read_u64(dn, "opal-entry-address", &val);
>> + ret = of_property_read_u64(dn, "opal-entry-address", &val);
>> + if (ret)
>> + goto out;
>> ret = kexec_purgatory_get_set_symbol(image, "opal_entry", &val,
>> sizeof(val), false);
>> }
>> --
>> 2.17.1
>>
next prev parent reply other threads:[~2024-09-30 9:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-30 7:56 [PATCH] powerpc/kexec: Fix the return of uninitialized variable Zhang Zekun
2024-09-30 8:27 ` Christophe Leroy
2024-09-30 9:01 ` Madhavan Srinivasan [this message]
2024-10-08 8:53 ` zhangzekun (A)
2024-11-17 12:09 ` Michael Ellerman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=67db60e6-8f61-4907-8a7c-93cd0d4cb034@linux.ibm.com \
--to=maddy@linux.ibm.com \
--cc=chenjun102@huawei.com \
--cc=christophe.leroy@csgroup.eu \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=naveen@kernel.org \
--cc=npiggin@gmail.com \
--cc=zhangzekun11@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).