Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp86411rdb; Tue, 31 Oct 2023 01:11:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHN0pYnGpUdZ8h77MdsYbZtzEZtghB9pD6971DJ5xoIP4OljfXXnklpfk1q4aWQyly3vASb X-Received: by 2002:a05:6a00:4792:b0:6c1:6695:a6df with SMTP id dh18-20020a056a00479200b006c16695a6dfmr1617089pfb.20.1698739866242; Tue, 31 Oct 2023 01:11:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698739866; cv=none; d=google.com; s=arc-20160816; b=mNiNwyG/GMfWMjWKrfNWbpjbBRYtBWC5Pd7pxHK5YRwXdqH3fm/mV26Clmvay6bEw2 YeHoZjd83cUQBLQVtX6zmAgJR2hVvLh6awz2uBeHpSqvThnUMG+b9bEkMbY2WVwwssCN OnctpRnxD+QwQqdCaRLHDFLT4MOcMSvNfCyMgt4ioI+EDv4B8BDQhrNK5XZF2JBhAxDp G6R2b8dQZgvqZJAOnDiHOYpmLmqWO+TOBpxI4TZORQPFya7u61p58OORunZyeLpbjpsy rO/jYXAOEdqzTEpR2Jf7fdgtrwVjR5KXEhxZ+xRNWvo6nA9jHGKcnS/1mOyShHle+zKL EuxQ== 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 :message-id:date:subject:to:from; bh=+j0gODmpDzoLINKiH53Vh9eP/cLQh7skDZ2s7JNb9RA=; fh=IauAIxnXBZatljtop+M5AORXOCNCRmAR0zOcCShS3Rc=; b=ZHlsL9z8Dp1Wo1gp58WAntr6AFd9lrbE3AkS5qqfxnzd9P/G8nGthI1o0xAaCf4vsn hniZlB+3kV/EaAEt/GLgVqXPk/bFECZXnRg1iAU1Zze4Sf9RsvBACGLhi4RHI3VBgqIO 1v+29bq2rfp2FkhZTkqyhUXw0vqKRBCJjC/J+PNOPJ8cz5sROsXAriugoPAgBy4w/lOc V9nrTMwRreAUK7YdCJ+rsXsJclD/18nejF1VVWoC0xcXk2xe6yxVg5zObto7uDzlP74W OaQ0x8Dakj7wIxaLCBo3/s/D7jCxeIAeFOE2pLtPgimI1++RNoVkaeYbkvVyqvtQdrLP 9rlw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id z17-20020a056a00241100b006c0fef93179si674392pfh.223.2023.10.31.01.11.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 01:11:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 7BEB98068230; Tue, 31 Oct 2023 01:10:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231712AbjJaIKK (ORCPT + 99 others); Tue, 31 Oct 2023 04:10:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230457AbjJaIKH (ORCPT ); Tue, 31 Oct 2023 04:10:07 -0400 Received: from cstnet.cn (smtp84.cstnet.cn [159.226.251.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F7C2C1 for ; Tue, 31 Oct 2023 01:10:04 -0700 (PDT) Received: from localhost (unknown [124.16.138.129]) by APP-05 (Coremail) with SMTP id zQCowADXcJRHtkBlw4i_AQ--.26667S2; Tue, 31 Oct 2023 16:09:43 +0800 (CST) From: Chen Ni To: linus.walleij@linaro.org, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, robh@kernel.org, geert+renesas@glider.be, jernej.skrabec@gmail.com, valentin.caron@foss.st.com, bero@baylibre.com, nichen@iscas.ac.cn, dario.binacchi@amarulasolutions.com, linux-gpio@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] pinctrl: stm32: Add check for devm_kcalloc Date: Tue, 31 Oct 2023 08:08:07 +0000 Message-Id: <20231031080807.3600656-1-nichen@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: zQCowADXcJRHtkBlw4i_AQ--.26667S2 X-Coremail-Antispam: 1UD129KBjvdXoW7Wr18Cr4DZrWfJw1fWFyxGrg_yoWDJwc_CF y8J34DGFyj9r97Ar1jqrn5ZF9Y9F4DZw109rsYqF13Cr9xuw15GrWkXr17Gws7CF13tasx GFyj9ry3JrW7AjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbVkFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr0_ Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AKxVWxJr 0_GcWle2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r4j6F4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lFIxGxcIEc7CjxVA2 Y2ka0xkIwI1lc2xSY4AK67AK6r43MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r 1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CE b7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0x vE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAI cVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2Kf nxnUUI43ZEXa7VUjFksDUUUUU== X-Originating-IP: [124.16.138.129] X-CM-SenderInfo: xqlfxv3q6l2u1dvotugofq/ X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 31 Oct 2023 01:10:18 -0700 (PDT) Add check for the return value of devm_kcalloc() and return the error if it fails in order to avoid NULL pointer dereference. Fixes: 32c170ff15b0 ("pinctrl: stm32: set default gpio line names using pin names") Signed-off-by: Chen Ni --- drivers/pinctrl/stm32/pinctrl-stm32.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c index a73385a431de..419eca49ccec 100644 --- a/drivers/pinctrl/stm32/pinctrl-stm32.c +++ b/drivers/pinctrl/stm32/pinctrl-stm32.c @@ -1378,6 +1378,11 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl, struct fwnode } names = devm_kcalloc(dev, npins, sizeof(char *), GFP_KERNEL); + if (!names) { + err = -ENOMEM; + goto err_clk; + } + for (i = 0; i < npins; i++) { stm32_pin = stm32_pctrl_get_desc_pin_from_gpio(pctl, bank, i); if (stm32_pin && stm32_pin->pin.name) -- 2.25.1