linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yunfeng Ye <yeyunfeng@huawei.com>
To: Will Deacon <will@kernel.org>
Cc: <catalin.marinas@arm.com>, <will.deacon@arm.com>,
	<kstewart@linuxfoundation.org>, <gregkh@linuxfoundation.org>,
	<tglx@linutronix.de>, <info@metux.net>,
	<linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] arm64: armv8_deprecated: Checking return value for memory allocation
Date: Mon, 7 Oct 2019 14:06:47 +0800	[thread overview]
Message-ID: <0763a3af-16ed-d450-4980-0e6b69b06bee@huawei.com> (raw)
In-Reply-To: <20190930132209.jyyemkck7orji64i@willie-the-truck>



On 2019/9/30 21:22, Will Deacon wrote:
> On Sun, Sep 29, 2019 at 12:44:17PM +0800, Yunfeng Ye wrote:
>> There are no return value checking when using kzalloc() and kcalloc() for
>> memory allocation. so add it.
>>
>> Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
>> ---
>>  arch/arm64/kernel/armv8_deprecated.c | 5 +++++
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/arch/arm64/kernel/armv8_deprecated.c b/arch/arm64/kernel/armv8_deprecated.c
>> index 2ec09de..ca158be 100644
>> --- a/arch/arm64/kernel/armv8_deprecated.c
>> +++ b/arch/arm64/kernel/armv8_deprecated.c
>> @@ -174,6 +174,9 @@ static void __init register_insn_emulation(struct insn_emulation_ops *ops)
>>  	struct insn_emulation *insn;
>>
>>  	insn = kzalloc(sizeof(*insn), GFP_KERNEL);
>> +	if (!insn)
>> +		return;
>> +
>>  	insn->ops = ops;
>>  	insn->min = INSN_UNDEF;
>>
>> @@ -233,6 +236,8 @@ static void __init register_insn_emulation_sysctl(void)
>>
>>  	insns_sysctl = kcalloc(nr_insn_emulated + 1, sizeof(*sysctl),
>>  			       GFP_KERNEL);
>> +	if (!insns_sysctl)
>> +		return;
> 
> Since both of these failure paths are fatal to the instruction emulation,
> can you please return an error code when the allocation fails and use that
> to fail the calling initcall() appropriately?
> 
ok, I will modify as your suggest, thanks.

> Will
> 
> .
> 


      reply	other threads:[~2019-10-07  6:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-29  4:44 [PATCH] arm64: armv8_deprecated: Checking return value for memory allocation Yunfeng Ye
2019-09-30 13:22 ` Will Deacon
2019-10-07  6:06   ` Yunfeng Ye [this message]

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=0763a3af-16ed-d450-4980-0e6b69b06bee@huawei.com \
    --to=yeyunfeng@huawei.com \
    --cc=catalin.marinas@arm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=info@metux.net \
    --cc=kstewart@linuxfoundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=will.deacon@arm.com \
    --cc=will@kernel.org \
    /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).