Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2574793imw; Sun, 10 Jul 2022 09:41:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sxuTB/XhUUKC3ydIvRExVgmxtg0O9umO8pQo9Eix9IP5RApmG7lNRCOxgKHWLayjLJpW0Q X-Received: by 2002:a05:6a00:1a44:b0:528:6af7:ff4a with SMTP id h4-20020a056a001a4400b005286af7ff4amr14480551pfv.78.1657471261415; Sun, 10 Jul 2022 09:41:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657471261; cv=none; d=google.com; s=arc-20160816; b=Sy1N6DrGGNx0003NkAV/tsk5xopuXH4rQIlPZCiESa5GIqPRveJWtnHVxCFTFE61ao p35d99LpC5Dkav5TYJQ5HduLpa9ETpndC35wqJ7rXvA64wx8Rl0AbzV+SmEdHkaihLgj 1yyXMiQiGNvBurgiZy8KV+Uy2LU9rHF1sJZqYSQY0U4O6aSZJ+7yyS9Y9WYEsY8gF5zm COKRMMkNwFH/fbf67nDBFTbVvwy9dOjwliRkxTapCBzbW7bsdDSjkKPFKxLJCpGfePG8 MfEZccu62173aCB4z47uE9Kt2n2sRwQg4cEIKLhHJidPiWb9NwuFkxoKTY+SjQJYM24W h9jA== 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:cc:to:from:dkim-signature; bh=Vn4naovKTOZQthrjfaP/ehRTLiCmrzMOGVk+9JX62aE=; b=YQyODAlzzCk3zfk0nVEJrVt4hLAbUIxdp8igd+YcVKOLfeB7MHITV5lRxFmlHOrBTE nzjB4sc3ougK0N/6KiHX+Kfrc83dkUGglg+/LLbaMPssjx6fFNJgbwv2IIc+J5jVMQZd A3GUkz9xkwgVbQdefesMRSWg0BAoS+5d7Zpe+rKCC7OZtvQtzmUXc105w1WB12dH66EL 9RuVGLdWYgYtxomR+wSrEjsskP8AfJv55gtXoLXFGi1O21v3Nr0BsuU8VGEE8QRdsJDL ZSMEvKti9Lk3qLgyYnegKtqpgl+AhJHFw7+PdGPqxt02Jw/ChYEFCHvh/edFo8KZDwgg WZvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=F1KUBvAf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u6-20020a170902b28600b001676128d04bsi6257577plr.413.2022.07.10.09.40.49; Sun, 10 Jul 2022 09:41:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=F1KUBvAf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229648AbiGJQGO (ORCPT + 99 others); Sun, 10 Jul 2022 12:06:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229477AbiGJQGN (ORCPT ); Sun, 10 Jul 2022 12:06:13 -0400 X-Greylist: delayed 954 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sun, 10 Jul 2022 09:06:07 PDT Received: from mail-m975.mail.163.com (mail-m975.mail.163.com [123.126.97.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 066E012ACD; Sun, 10 Jul 2022 09:06:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=Vn4na ovKTOZQthrjfaP/ehRTLiCmrzMOGVk+9JX62aE=; b=F1KUBvAfY9Xhge8HUoIqp s2QIWtrjjeAKg2hkUhMwfBxsnSqZ0aIwppfw1HjZww0WrR9C5Quvz7/4gLXPb+sB SdNdDxgEV2KkhlFPGxz2Wrd7/ox15HG8Eh2A8615v7nyiYdXuLp3A11srtXuauoM IuKWgXc4jKalDUZjR1qcVE= Received: from localhost.localdomain (unknown [123.58.221.99]) by smtp5 (Coremail) with SMTP id HdxpCgCHlzED9cpiFZjPNQ--.1936S2; Sun, 10 Jul 2022 23:49:25 +0800 (CST) From: williamsukatube@163.com To: arinc.unal@arinc9.com, sergio.paracuellos@gmail.com, linus.walleij@linaro.org, linux-mips@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: William Dean , Hacash Robot Subject: [PATCH] pinctrl: ralink: Check for null return of devm_kcalloc Date: Sun, 10 Jul 2022 23:49:22 +0800 Message-Id: <20220710154922.2610876-1-williamsukatube@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: HdxpCgCHlzED9cpiFZjPNQ--.1936S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7ZrW7Zw48Xw1fKw4fKryDKFg_yoW8JF4xpF 43ur15Ary5JrsrZFWjywnrZry3Wa18KrW3Ga4j9rZFvF45Aas7Cay5Krs2qrWDCrWkuw13 tr4aq342gFykAFUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07b4_-dUUUUU= X-Originating-IP: [123.58.221.99] X-CM-SenderInfo: xzlozx5dpv3yxdwxuvi6rwjhhfrp/xtbBiAY6g1aECCBQGAAAsF X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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: William Dean Because of the possible failure of the allocation, data->domains might be NULL pointer and will cause the dereference of the NULL pointer later. Therefore, it might be better to check it and directly return -ENOMEM without releasing data manually if fails, because the comment of the devm_kmalloc() says "Memory allocated with this function is automatically freed on driver detach.". Fixes: a86854d0c599b ("treewide: devm_kzalloc() -> devm_kcalloc()") Reported-by: Hacash Robot Signed-off-by: William Dean --- drivers/pinctrl/ralink/pinctrl-ralink.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pinctrl/ralink/pinctrl-ralink.c b/drivers/pinctrl/ralink/pinctrl-ralink.c index 63429a287434..770862f45b3f 100644 --- a/drivers/pinctrl/ralink/pinctrl-ralink.c +++ b/drivers/pinctrl/ralink/pinctrl-ralink.c @@ -266,6 +266,8 @@ static int ralink_pinctrl_pins(struct ralink_priv *p) p->func[i]->pin_count, sizeof(int), GFP_KERNEL); + if (!p->func[i]->pins) + return -ENOMEM; for (j = 0; j < p->func[i]->pin_count; j++) p->func[i]->pins[j] = p->func[i]->pin_first + j; -- 2.25.1