Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2064414pxb; Fri, 25 Mar 2022 10:27:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyG7sVWqkuv1aocwCuG3hStnRuuve0xRTnpzbegmeudI8SUIdIjXObnUF8lRmLc2qL4DNv8 X-Received: by 2002:a63:1b48:0:b0:384:4dff:5dbb with SMTP id b8-20020a631b48000000b003844dff5dbbmr530125pgm.238.1648229238360; Fri, 25 Mar 2022 10:27:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648229238; cv=none; d=google.com; s=arc-20160816; b=zsrq3jOtye8qJ9v3FLH74LB2/5BaBpp+haUQAXfZslP0IQGhpmNSFYiLZRNAEOHnv2 kpCKP9Arf2bV+uta9IRO2PhsR6zZ3uGNZ2JMpJkhO5PRt13CL/NsxB7pGsjg7Oa+geex lELCbjV4du3tbkmJAMdSw98d/R9buWydBIqE7t2nuoNPnShlDO+0/HUP9KpTl1HY7D88 pz+idKGKdK5h0EpQPZMf9YUxqfMspUK8itNWpKwn/FWR7jM7qyv7AAsrF3gHMNrtr31T OOvXfUKctqt8XQNTgmSe9UrD+yr3b5Sa2eoEE7fxKMGTpZtR6Owxhtw6VJX0J2rFy915 apNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version:date :subject:cc:to:from:message-id:dkim-signature; bh=r7MTF35xCe4CtzCMUlH4AuHMMOLVBgWolF8Nu+I39t8=; b=rWb8FeSSHqr29S6FAYiWXjvleqwh11FT11xmnTmPe5c5nGfhhsOm6HvzJay8yg2Nj2 BZrObdob5HiyK5Kp1p8GNh3jU63xx8wZD8hclWS7Hr1NIn39NX8Io0DnInuPnHz389tc 3Mc3FlcDIeLoheI0bZyliTm1Zm2vPNmgj/Dif0xxw9srGmZP06WzwwrV/nsEmnQ2FTOk Dt3/NaCI+J7eUf5Y2NkUdRuF1j5oNjdhYOowmevx8ae/oq0lka/ItVC9Y9Xw6eTcKWw9 NMcUQ2gHxmoZlkFDj7VtiG86/Rmk4pJf2aOy7e2ewwZAOW8Iw1ZgIf8JA1yLm9nRoNLW uG8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=e5FazAwF; 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=foxmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id pi14-20020a17090b1e4e00b001bf866c6bb9si7038175pjb.190.2022.03.25.10.27.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 10:27:18 -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=@foxmail.com header.s=s201512 header.b=e5FazAwF; 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=foxmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 74DB9FFFB4; Fri, 25 Mar 2022 10:21:30 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358909AbiCYKga (ORCPT + 99 others); Fri, 25 Mar 2022 06:36:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356758AbiCYKg3 (ORCPT ); Fri, 25 Mar 2022 06:36:29 -0400 Received: from out162-62-57-137.mail.qq.com (out162-62-57-137.mail.qq.com [162.62.57.137]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A51AFB6D3C for ; Fri, 25 Mar 2022 03:34:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1648204489; bh=r7MTF35xCe4CtzCMUlH4AuHMMOLVBgWolF8Nu+I39t8=; h=From:To:Cc:Subject:Date; b=e5FazAwFDmuHogT0CQVByFlmkgCsCWPZOYvLaqVkODR8iSQM+ZIW+uWrPh07cMBdx AhuJQm/5tZyIIaG/zy14Zf5bkR8yRmz3tqmyo1pA22krd2DY/HHdQqwNGe3SREpJ1V iK792qqeD4GB2gG4PeupWvBhtbHu5qzljXm7B+KA= Received: from localhost.localdomain ([218.197.153.188]) by newxmesmtplogicsvrszc11.qq.com (NewEsmtp) with SMTP id 6DFA0EBB; Fri, 25 Mar 2022 18:27:31 +0800 X-QQ-mid: xmsmtpt1648204051tp1m08xmo Message-ID: X-QQ-XMAILINFO: OOWntbL6xj16UYjmDCYdk3zdV6AkUlVJYVXvFXwyqwiwhHIj+QucYg/rjcEuOt YO7j/eprBmyc4h2c06wgdcYMWSep4SXwq7n+QGxdcp6ICsFbd9yTBd2y9WzUKB2YwYvs/h8Mu+NF 3O/awHA4MLl1CeBeM8HFfgPZWH4/vqzvwiDrMgaZ1iu7C+gGmhfen9xCWY78+E9vsdumUiwchXp4 mJ73wtlnQeZQVQvB0aU6xAs+7niZUpJswpFFx/U+6co38r4urXkGPe7qIJSEtptS8cCk3XI76bTp GBE+6cG8pXUfIhIIY9a7UwUFabdQ/611P/rXY4ZbxNXiy8imWSu0q73DKFp1Msl/Pa6B+f5RKrac sSm5Px8sotmHtHcqLRGQL365aXb8G3bBusnZsNdweoK6RnKfba5j1ExXohhWM3FWaZVb01iUwIjO pT0uKiE2iQVbdhmVfWnzg2WAg+6AXI+v+dsz4HXd4ir0CpdQyG4Mib4UAQ2w64jYH+G2tUmzeiO9 9N+Ovt6E8HcR0Tgr/s+oXNSDCJh9CgsVSGZnTQUqi93ePXrydTOfbWsoZ0bm/3w7cdnlXn6pNOF9 40+wNNghlHZdV0tlfWByU4qL02Q62qlEokvhYrJA08qEVbWsPgtdDnFlY2pEOyogx28ge0OdJ2+m uVRokNyTXZOSXJFejgBRQH3MwBIxrMvlEuN81q5FUuHsBCfxmqKB3NrQcjYDGNjsWOA7q/UFbbU8 0RgF7ducb3U9hMY0DCyV5rs3grDP+0m82+2Fxk+Bgc47ZWsWcTGnKI23eMDlfDInZFmuP8CXDGfo 3F5LJfdBoqKuPXyuapA6uM02us/UpXvP6ex3EJV25oaVzPNcIvty5n3vPl95GMhOiXT+jqXPdXYX uhv4HuJcsBQ3Sq8KD4AmLy27zc0kW4D6QVRKYYc1Ma8FrYOrL8GxLkNokTZ7YcnIA0Tdh2vAxPmH erom5GfnM= From: xkernel.wang@foxmail.com To: mturquette@baylibre.com, sboyd@kernel.org Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Xiaoke Wang Subject: [PATCH] clk: pxa: add a check for the return value of kzalloc() Date: Fri, 25 Mar 2022 18:27:20 +0800 X-OQ-MSGID: <20220325102720.4155-1-xkernel.wang@foxmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 From: Xiaoke Wang 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. Signed-off-by: Xiaoke Wang --- drivers/clk/pxa/clk-pxa.c | 2 ++ 1 file changed, 2 insertions(+) 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_cken *clks, int nb_clks) for (i = 0; i < nb_clks; i++) { pxa_clk = kzalloc(sizeof(*pxa_clk), GFP_KERNEL); + if (!pxa_clk) + continue; pxa_clk->is_in_low_power = clks[i].is_in_low_power; pxa_clk->lp = clks[i].lp; pxa_clk->hp = clks[i].hp; --