From mboxrd@z Thu Jan 1 00:00:00 1970 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 7D342CD5BC9 for ; Thu, 5 Sep 2024 14:53:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:References:CC:To: Subject:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vbqxVfYbjVgl4NrdmPWrSvt1JZy91eHgLK28VSG2Ln8=; b=h/sP4YePWz6V5ezBVgG8TPYmK8 FsGX61T/BoMYA6AppGZkAcCWMtpJMdAZl7HnSSE0lTmeCDfGAYfO5nEsvk5sBCa7KqQyA31dBPvtp tcjdWmGwmkE1APjrynnlaViYsGJYvEBun8qgIQjx9KAYw1ZBwg+yU4YCwSpBIOn6d8xW6qKfdQURZ 0/2V2taGDjnBC8Ifx26s8geUJcXkD64Iv35/uetrzMyO881W4byPASxpVK1/yrOY8DKKlrBqUVxO9 EUHy5PBRYB0mpDBe7Gjb1b/yXsmDuQ7AUc1PHp/L5OxmGGGyfLqwW+Y3890pJqQaHGq1SuPWPX9ll 9taGuoQw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smDri-00000008oJh-1PUt; Thu, 05 Sep 2024 14:53:42 +0000 Received: from mx01.omp.ru ([90.154.21.10]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smDp3-00000008nLV-2Y91 for linux-arm-kernel@lists.infradead.org; Thu, 05 Sep 2024 14:50:59 +0000 Received: from [10.185.68.150] (90.154.15.122) by msexch01.omp.ru (10.188.4.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1258.12; Thu, 5 Sep 2024 17:50:28 +0300 Subject: Re: [PATCH] pinctrl: stm32: check devm_kasprintf() returned value To: Ma Ke , , , , , , , , , CC: , , , , References: <20240905020244.355474-1-make24@iscas.ac.cn> From: Sergey Shtylyov Organization: Open Mobile Platform Message-ID: <03cf48b6-58b4-eeaa-41bf-5dda61ea37ac@omp.ru> Date: Thu, 5 Sep 2024 17:50:28 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20240905020244.355474-1-make24@iscas.ac.cn> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [90.154.15.122] X-ClientProxiedBy: msexch01.omp.ru (10.188.4.12) To msexch01.omp.ru (10.188.4.12) X-KSE-ServerInfo: msexch01.omp.ru, 9 X-KSE-AntiSpam-Interceptor-Info: scan successful X-KSE-AntiSpam-Version: 6.1.1, Database issued on: 09/05/2024 14:36:50 X-KSE-AntiSpam-Status: KAS_STATUS_NOT_DETECTED X-KSE-AntiSpam-Method: none X-KSE-AntiSpam-Rate: 59 X-KSE-AntiSpam-Info: Lua profiles 187573 [Sep 05 2024] X-KSE-AntiSpam-Info: Version: 6.1.1.5 X-KSE-AntiSpam-Info: Envelope from: s.shtylyov@omp.ru X-KSE-AntiSpam-Info: LuaCore: 32 0.3.32 766319f57b3d5e49f2c79a76e7d7087b621090df X-KSE-AntiSpam-Info: {rep_avail} X-KSE-AntiSpam-Info: {Tracking_from_domain_doesnt_match_to} X-KSE-AntiSpam-Info: {relay has no DNS name} X-KSE-AntiSpam-Info: {SMTP from is not routable} X-KSE-AntiSpam-Info: {Found in DNSBL: 90.154.15.122 in (user) dbl.spamhaus.org} X-KSE-AntiSpam-Info: d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;127.0.0.199:7.1.2;90.154.15.122:7.1.2;omp.ru:7.1.1 X-KSE-AntiSpam-Info: FromAlignment: s X-KSE-AntiSpam-Info: ApMailHostAddress: 90.154.15.122 X-KSE-AntiSpam-Info: {DNS response errors} X-KSE-AntiSpam-Info: Rate: 59 X-KSE-AntiSpam-Info: Status: not_detected X-KSE-AntiSpam-Info: Method: none X-KSE-AntiSpam-Info: Auth:dmarc=temperror header.from=omp.ru;spf=temperror smtp.mailfrom=omp.ru;dkim=none X-KSE-Antiphishing-Info: Clean X-KSE-Antiphishing-ScanningType: Heuristic X-KSE-Antiphishing-Method: None X-KSE-Antiphishing-Bases: 09/05/2024 14:40:00 X-KSE-Antivirus-Interceptor-Info: scan successful X-KSE-Antivirus-Info: Clean, bases: 9/5/2024 12:11:00 PM X-KSE-Attachment-Filter-Triggered-Rules: Clean X-KSE-Attachment-Filter-Triggered-Filters: Clean X-KSE-BulkMessagesFiltering-Scan-Result: InTheLimit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240905_075057_700628_B906ED1E X-CRM114-Status: GOOD ( 19.03 ) 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 On 9/5/24 5:02 AM, Ma Ke wrote: > devm_kasprintf() can return a NULL pointer on failure but this returned > value is not checked. Fix this lack and check the returned value. > > Found by code review. > > Cc: stable@vger.kernel.org > Fixes: 32c170ff15b0 ("pinctrl: stm32: set default gpio line names using pin names") > Signed-off-by: Ma Ke > --- > drivers/pinctrl/stm32/pinctrl-stm32.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c > index a8673739871d..53306d939d14 100644 > --- a/drivers/pinctrl/stm32/pinctrl-stm32.c > +++ b/drivers/pinctrl/stm32/pinctrl-stm32.c > @@ -1374,8 +1374,13 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl, struct fwnode > > 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) > + if (stm32_pin && stm32_pin->pin.name) { > names[i] = devm_kasprintf(dev, GFP_KERNEL, "%s", stm32_pin->pin.name); > + if (!name[i]) { > + err = -ENOMEM; > + goto err_clk; > + } > + } > else > names[i] = NULL; That doesn't comply with the kernel coding style -- it now needs to be: } else { names[i] = NULL; } [...] MBR, Sergey