Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp6946502ybn; Mon, 30 Sep 2019 06:23:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqyInD3cKPqWN5jyScSaYCUzgVIwFZPntWCp1WncaQtBA8DPaJudnJF/72qFJWi7Vtyib1MW X-Received: by 2002:a50:b7ed:: with SMTP id i42mr19112057ede.52.1569849790611; Mon, 30 Sep 2019 06:23:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569849790; cv=none; d=google.com; s=arc-20160816; b=VAk8GtBsyTV0LergWZCSkq6eMudqYA6XcpOFKfnRdJX0ZXWTP55SiB/Eh4YXk1QYzd Dt5zC2YqZMTf56bATr6DIbqdjol+r4qgzctNG26HCcRQXkt6+WTKtkIsDjAuhBKpFzLB Zmb1KP9KgwfYv6RZrF2ptpLp64czXg5xqh0N9IreDHqvFfFbDc+AfNB6cqnz4iDi1w1K sXf6btCDhip9GNQpX9qk2/sFxHvbO9fq/YLKi9NZbJSaPvWy5O2N+/n/bBjvoe3mAi1z rGeT1Bx0I/M9kZXBPALz0YeIxQxC5NrNXSGf2DQmZ5/WOx8UibKqD4/wO6+xlRkUTmOV QrUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=i01UhYOP+0mhDGoGefVN3HtxFv1bT/jmZuMo1FQt+04=; b=sY3bYLPF6R+aBqUzUClHhMR/pboF8eLS/JSeJV1f4PHkVFipn/WIK1EEtDCshXdbyE 1tX2KlLVL7QloJksftS6x4VO3A4pznAn7gSnDx/UukgXqbhJwihR8hvM4yG+Fpe7YTPk jSi5l/3PntWeJahxTe1RoB6ltquEpC25s3HLLbcQaCzr1K5AWLlYY7Dj2iJSmI7PaHaW 7UhUcoUNir+GWpWY8z4/lAZ0G3AcyDcaV8qz8WZIN3mY4poNi8eUshSzSpVSw4DnR79K aSq3xB8q/0nKLUsaoesyiq8A1kNWPlbNdsjVRcgnkevcXsnBxJtBIgiK15VQLrQEtnrQ OJBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1d0oL1ar; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d27si7452569ede.381.2019.09.30.06.22.46; Mon, 30 Sep 2019 06:23:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1d0oL1ar; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731136AbfI3NWP (ORCPT + 99 others); Mon, 30 Sep 2019 09:22:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:55594 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730266AbfI3NWP (ORCPT ); Mon, 30 Sep 2019 09:22:15 -0400 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2384120842; Mon, 30 Sep 2019 13:22:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569849734; bh=5YgzqjSTmNEx7qj7fQeG6vrEjnUn7W/lfum0s/DKHGY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=1d0oL1arMIQkT3rZLOZ6EqO21ByQGs1tnW7R8kZ5o2NUeo28JRXzi9RVhryn48xaa dGD0ACOAKudBKKq9x8/KquD18TBawUJJYQnVvLLd6iZu/DCDnPVUOVwEY/HvV2IMcl BjtBvC8uqVeTuJT5Z+lIt/fWQRlvOiaOrEnFF/Mc= Date: Mon, 30 Sep 2019 14:22:10 +0100 From: Will Deacon To: Yunfeng Ye 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 Message-ID: <20190930132209.jyyemkck7orji64i@willie-the-truck> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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? Will