Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp62466pxh; Thu, 7 Apr 2022 14:02:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrFhSbXSaJJ8XqN9J8R6zcl8KF9aCsQJJKS+NthxdscsfvzsScgtK3zUbD3HlptmtgtZ5g X-Received: by 2002:a63:2b8b:0:b0:398:a502:f41f with SMTP id r133-20020a632b8b000000b00398a502f41fmr12741811pgr.17.1649365359730; Thu, 07 Apr 2022 14:02:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649365359; cv=none; d=google.com; s=arc-20160816; b=SbAKTqdxQG1UkWf82R6Flt7eGxOZx2qJ94WYv63SmW97LToirlV4uMjr0zGiIDB+aS M4WEmFIyC0oA+mp29CHmAO5kmNR7RR9yK6RpL3xFrHHpIiXdIIDAEiyyROsJ/cdDnBik W++Z5B4fFFeuEy1t7YO6DIdH+ujJAW+VLtu37X0wwEiVQxLVH4mbJu+gXKPyjwDdsYjD yZXsvN3+x0std0xTTOpBV8UAuY4wD848sb+WEK64X9dk7y7MxoW4Rc41Mcg8fpsisY53 9UYyEst932uccnj4WVXsYexHz/rM+7oT9n3smRAQ4hFOruEa/EFQzRDiShstHEPc90dv QReg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:user-agent:date:to:cc:from:subject :references:in-reply-to:content-transfer-encoding:mime-version :dkim-signature; bh=LN1Loi3cZH9Or+FARr0ApODVWr1D2kebSTFBgcPv44E=; b=xxajeebHZhnKunyv/FybDgQfWyoLwIlq2jMxFWM+LU4FoyFImLqayZzCnxqpatjYM/ 6flYRfxvQom5NetCyyiAZuxsrHWWzkrJ40kOelm5eV9WWS4S7ViKdqJ+BSQhhDPCKC0i KGgl0Wn8ZKZU34r7tTUeJ/hR4Rk8BbfC5zoS5B83PU/Ca9lDCY8FU3CoMndIRJKN1zdK 1rMs9HWsGJisZFg0MBAxpDcJjcYZanWwGYHHYr8hqN49eo6oBs70WWinKQ4yEzGXfn4G mhDteRtRzocz9TYg5hM1gzd9N3N5phgolpLSycrSwHH3Fpzg/MlW05IofnIjFdeozHSb fBbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hZSIYtqg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id z10-20020aa7888a000000b004fa3a8dffc4si20111980pfe.123.2022.04.07.14.02.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 14:02:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hZSIYtqg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3CFC22AD0AB; Thu, 7 Apr 2022 13:07:34 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240610AbiDGDgM (ORCPT + 99 others); Wed, 6 Apr 2022 23:36:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231231AbiDGDgL (ORCPT ); Wed, 6 Apr 2022 23:36:11 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4F69229CA6; Wed, 6 Apr 2022 20:34:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 61D66B8269A; Thu, 7 Apr 2022 03:34:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC889C385A1; Thu, 7 Apr 2022 03:34:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649302449; bh=CzpCh+DZuA4tm7ZwIdm62bJnfKCjs5B1CyTpOTHCkLo=; h=In-Reply-To:References:Subject:From:Cc:To:Date:From; b=hZSIYtqgBssFY8OJg0G93whVvaL7mppBNXCidYafwXTIns3GAriHoGIS8jL1wMvFU 8qIhlBB5hgfFxzLtAM46Z5lGE5eaZNzINj51Lm5c35zApxE4H9ZGW4YxmsiFDegR/q cI5g9L8xxwjwjMVYFe/Tfv6fCxL246luicP4eXBAqT2tMnltZ1WS7Gm2vD0GCo1/SO V5uvaLY9DeCQByvljwYdZ4zOVsIcuwrjGmcn3mKSrNBNMKT0h9jELouVkTukO3EPwc 42Tqt3rLrC8XpcH5zkG18qkYPGyouhqocCIs4+e1EO/3ZpCS0DYqzfjrhcVkP60u6U 5xibJFeihjwLw== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: References: Subject: Re: [PATCH] clk: pxa: add a check for the return value of kzalloc() From: Stephen Boyd Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Xiaoke Wang To: mturquette@baylibre.com, xkernel.wang@foxmail.com Date: Wed, 06 Apr 2022 20:34:07 -0700 User-Agent: alot/0.10 Message-Id: <20220407033409.DC889C385A1@smtp.kernel.org> X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting xkernel.wang@foxmail.com (2022-03-25 03:27:20) > From: Xiaoke Wang >=20 > kzalloc() is a memory allocation function which can return NULL when > some internal memory errors happen. So it is better to check it to > prevent potential wrong memory access. >=20 > Signed-off-by: Xiaoke Wang > --- > drivers/clk/pxa/clk-pxa.c | 2 ++ > 1 file changed, 2 insertions(+) >=20 > diff --git a/drivers/clk/pxa/clk-pxa.c b/drivers/clk/pxa/clk-pxa.c > index cfc79f9..d0df104 100644 > --- a/drivers/clk/pxa/clk-pxa.c > +++ b/drivers/clk/pxa/clk-pxa.c > @@ -102,6 +102,8 @@ int __init clk_pxa_cken_init(const struct desc_clk_ck= en *clks, int nb_clks) > =20 > for (i =3D 0; i < nb_clks; i++) { > pxa_clk =3D kzalloc(sizeof(*pxa_clk), GFP_KERNEL); > + if (!pxa_clk) > + continue; Shouldn't we stop trying to allocate more and return an error?