Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp3900919ybp; Sun, 6 Oct 2019 23:09:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqyMoj4gMbl1OfNlBwOhMoerOaDJQJlzTN7/JmESk4VPJkrLZX80rnIJe2C6GJQjlQh1Hkje X-Received: by 2002:a50:d6db:: with SMTP id l27mr27666081edj.164.1570428588319; Sun, 06 Oct 2019 23:09:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570428588; cv=none; d=google.com; s=arc-20160816; b=ucXgC9LMpjUgeq/6E3HWJeNryKPp3iuNZ2dAM8CWKj2Y68H3qy4xRM8AjB+VFCH6zq 7DQafFqU/60bqGxOe7be3drrzdvZFrPb2iJRlbnKqu2r0/P3wH4nXx2T97OSmj6HvUxG REb0MoN7vOYgCJ41KUx0PtZbzKYbU3kot2yMOLrKOeNdSZiTDWXIRkiaorgn6ZJqjKKG TMnoFstV+OLqwg6jDADVgLNa3xfzaniYHB9CMR55Mc7pzxS1owwuvBP9EGRFlA+MHqnQ yF3SgEm9I9q+HFIm9OkXhAnjjkdEUvYENEOoqmvcyKqBLjL/4xDUtEIyaIkZq4OZNfMS ilTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=ZGGXfdMsdwbVJesFnmVDhnrMQMmNttOYiL8H+8RYqwc=; b=t+UeAdNgHazkcnkTpIz3Fjm/zSezel2elE3SFhcgTV5vss2KdBaFfmGSJGxkuBVyyU 8zeXNZu93sXX417xcxrh5UYcQMxB/uuXhZlJrpiGqicUun8d08usgQtZbYT59qastfPH ZKe7ghXZsyapb1ImpWLfwxM7ALyyq5Srp8GfYUxbN2R+CG2DVPzxOKKTk5CrA9n6i+/9 O25QRLnZTg472IDpCdPHsuQEqnlm+bYe6hMNex0QMfIAadmO6Wk5Y+Z8NZR0TJ1Y5QGi /thDRHK/a1zn7byWEnKUV995yS89lurvF4a1s1jzctc4F86SvrmhHOcGK4WHLSJBTyCn 11ZQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g17si6500679ejd.123.2019.10.06.23.09.25; Sun, 06 Oct 2019 23:09:48 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727212AbfJGGGy (ORCPT + 99 others); Mon, 7 Oct 2019 02:06:54 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:3261 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726889AbfJGGGy (ORCPT ); Mon, 7 Oct 2019 02:06:54 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 7C42D154F83C0FCB6C57; Mon, 7 Oct 2019 14:06:52 +0800 (CST) Received: from [127.0.0.1] (10.177.251.225) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Mon, 7 Oct 2019 14:06:48 +0800 Subject: Re: [PATCH] arm64: armv8_deprecated: Checking return value for memory allocation To: Will Deacon CC: , , , , , , , References: <20190930132209.jyyemkck7orji64i@willie-the-truck> From: Yunfeng Ye Message-ID: <0763a3af-16ed-d450-4980-0e6b69b06bee@huawei.com> Date: Mon, 7 Oct 2019 14:06:47 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190930132209.jyyemkck7orji64i@willie-the-truck> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.251.225] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >> --- >> 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 > > . >