From patchwork Sun Jul 10 15:48:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: williamsukatube@163.com X-Patchwork-Id: 12912565 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1F625C433EF for ; Sun, 10 Jul 2022 15:50:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=rKuSVRT+ICkMXTCjvYnyByVp4Ht3S6qok+jPruzr4As=; b=KURFmrlqkU3WMH UgFpxnb3czdym4EJp23YfR45N5T+yuzMArw2MDZLp/Rd9fzN1d6aH16oFEF/+ugGNcupcTAn8VX0Z Rj8X667+99TDyrDnmDzBeiCjQzz/zAdColwqZ14CE3hYxoxLBY2R16h4WeUeqMlTTGECaGKUU8rgo CRc7Q0o4hb3CdMGFQ5cSZx5G/7ws38lxzsX6QcilQVa/wc1x8vHFnXg3Y98NivQ+TB0V80fzJJxTU 3UKMbRVW5PJ57Mih07JCdc0keH9z9LctyRpl1mG4E/AExruxHhUxlS5JxadQs3jtsUVsKJuzndeT7 GKxkbCQoqb2pvSsay00w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oAZAp-00CKlD-8g; Sun, 10 Jul 2022 15:48:43 +0000 Received: from mail-m971.mail.163.com ([123.126.97.1]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oAZAm-00CKjN-2g for linux-arm-kernel@lists.infradead.org; Sun, 10 Jul 2022 15:48:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=wBpy/ 1Al1S+IcisW01w7tkfDPuEkN3RCpqdYUq79uMk=; b=L2qeanDab5hW+MJJIpYm8 AwHM0BIZvvx6zPAZIEyFVNefvE9GrYp6jnUO1zz9p2svPvspJI+RoSxx83fNAofQ qHk+DdatyXsMS69ozlzcLhubohgUmCIP/Hg1bK3BUqL9pchWbFsscXzz0Yttx1Ok miq6BOmcdBXJyLtl5eQWLg= Received: from localhost.localdomain (unknown [123.58.221.99]) by smtp1 (Coremail) with SMTP id GdxpCgDX35_J9MpiqnY_Ng--.21432S2; Sun, 10 Jul 2022 23:48:29 +0800 (CST) From: williamsukatube@163.com To: dvorkin@tibbo.com, wellslutw@gmail.com, linus.walleij@linaro.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: William Dean , Hacash Robot Subject: [PATCH] pinctrl: Add check for kcalloc Date: Sun, 10 Jul 2022 23:48:22 +0800 Message-Id: <20220710154822.2610801-1-williamsukatube@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CM-TRANSID: GdxpCgDX35_J9MpiqnY_Ng--.21432S2 X-Coremail-Antispam: 1Uf129KBjvdXoWrtrWrKr4UKr17GF1fGr45KFg_yoWDWwc_ua yrWFyDXrWUKF1xtrsFqrn3W34Fvw45Zr1Fvr1vqFy3Aay7Xw1UJr1kuFs5Wwn7Wr98CFZx G3sFyr1Fya47KjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU5TWlPUUUUU== X-Originating-IP: [123.58.221.99] X-CM-SenderInfo: xzlozx5dpv3yxdwxuvi6rwjhhfrp/1tbiUQ06g2DEOjWbQAAAsV X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220710_084840_678013_6A4BA39D X-CRM114-Status: GOOD ( 10.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: William Dean As the potential failure of the kcalloc(), it should be better to check it in order to avoid the dereference of the NULL pointer. Fixes: aa74c44be19c8 ("pinctrl: Add driver for Sunplus SP7021") Reported-by: Hacash Robot Signed-off-by: William Dean --- drivers/pinctrl/sunplus/sppctl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pinctrl/sunplus/sppctl.c b/drivers/pinctrl/sunplus/sppctl.c index 3ba47040ac42..2b3335ab56c6 100644 --- a/drivers/pinctrl/sunplus/sppctl.c +++ b/drivers/pinctrl/sunplus/sppctl.c @@ -871,6 +871,9 @@ static int sppctl_dt_node_to_map(struct pinctrl_dev *pctldev, struct device_node } *map = kcalloc(*num_maps + nmG, sizeof(**map), GFP_KERNEL); + if (*map == NULL) + return -ENOMEM; + for (i = 0; i < (*num_maps); i++) { dt_pin = be32_to_cpu(list[i]); pin_num = FIELD_GET(GENMASK(31, 24), dt_pin);