From patchwork Wed Jan 17 17:41:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Elfring X-Patchwork-Id: 13522057 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 54D2DC47258 for ; Wed, 17 Jan 2024 17:42:23 +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:In-Reply-To:References:Cc:To:From: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=nJMMJvJEwWwsCxWkz2YoSXEivKO7mw85qaw2DKlj0M8=; b=kmnr3xRg0qmNig ysPRwNZHiHIHj8riIKvepJUxKuhJvSnuP+cvUmgttkPqhSIKpdAqpGMF1qYkPKgTj6+6pywI8x3an dtmosqbUmQ/+eYga4mR1lPL/bEdaGJ68cExsEvuI0qkdcfKA7QmpbH+FwdSlsWMVCe7UoL1I0salr tUQBFealv/PeevCNw5CDAJfig1hzBXQhmo95879rscSTErRkN8BOeoOB9emvQ207WnfHEmzAPhc7o JGJ8St8EWN8lcjFB273GE9tepRmqYkszHB7K2JPS+4tGp6hFl/7R3PTAKVxmQwet4hNUbeqHfXz0P B3U9z4yj7DZ3HZ1/8VVw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQ9vM-000G6Z-1C; Wed, 17 Jan 2024 17:42:00 +0000 Received: from mout.web.de ([212.227.17.11]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rQ9vJ-000G5j-18 for linux-arm-kernel@lists.infradead.org; Wed, 17 Jan 2024 17:41:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1705513308; x=1706118108; i=markus.elfring@web.de; bh=qBn4g41fb2MsxxM0gYc5dVcwvdfo1oczPv1z+8LJprE=; h=X-UI-Sender-Class:Date:Subject:From:To:Cc:References: In-Reply-To; b=l/2/DeRlD4+1yr47PalGJ2WO0/tcWrgRzfqOuOQNT3btCikjX1Jayg3vLDdr1AGr ixmsRJyLqaWKgeJ2Y3kcJ0AaPouJ34P+o+EamSI0XdimPZkiJ38weoP5rAeP0Xzb7 3efoixKB+bAZfSs2WtfvI2yh8jpaOHdd2KkBMLh/OLVKAWiVS0T2QXyZH/l9Uf/q8 +c8ONF0lL2oRpRRUwng6pwKvPEsCm+enHx3cqNXMPplih02yeqBW0bBXVHSHgKmQM r3VdPGU4HYLN4VClvNkQQiSHkIFTgxPW+gV0uzzBhZdCCuyrkojqw4J/9OIhU5ClY dq87w7caX0awOAQsiA== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.84.95]) by smtp.web.de (mrweb106 [213.165.67.124]) with ESMTPSA (Nemesis) id 1MnX1L-1qjiEj1L9h-00jOPl; Wed, 17 Jan 2024 18:41:48 +0100 Message-ID: Date: Wed, 17 Jan 2024 18:41:47 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 1/2] clk: versatile: clk-icst: Return directly after a failed kasprintf() call in of_syscon_icst_setup() Content-Language: en-GB From: Markus Elfring To: linux-clk@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Linus Walleij , Michael Turquette , Rob Herring , Stephen Boyd Cc: LKML , Kunwu Chan References: <061aef8b-a41f-4346-af6e-560c7594b27b@web.de> In-Reply-To: <061aef8b-a41f-4346-af6e-560c7594b27b@web.de> X-Provags-ID: V03:K1:NDbGmkn44kT6EPNjOFh/z2sQKhLIGQisz4KddKtA81uJh8rFwM1 Z+K9QMTIjfuFTWofHkYCfVrUYKxTGf1CQUzivIjm62B51PE50fl3yltVX11Pyfn3pQQZH5C N1FV4BmTJ+cET5rjb9opFFBePOk1oVx84BIsGhaT87rsLFSIvMa7Sz5Hj9VTJ89ScGyfH2R FuJ5tb576dfX1CsH0Pgvw== UI-OutboundReport: notjunk:1;M01:P0:MCdEgOisQlc=;2Ltz+7VFKKV6wYLiurTJ4Xz7xWp XO9AJ7SsFd+9QkXTVpbK8mq3fuepOOKScZduUT15kSykmD8mMVxZMdFtuozlKrhXaP+qcFsyJ SFF+IBo84eckhnSn3S0dwFiWh3apBdBNr/6e7zeDlUDZZY9hefWETc7h5kDaX3Is6yrbzOk0I bkmOzuSoRgxsZ6a/m1IIBR40/F9Pc81pAmrlQaJ2SUV+RLdaK7l8UIReGgN/+IUlk4P+gAPei rvm83OAjqA6Q7SvYb/iYD20Sl1x2z06FJe0ntHXth7tEUXB0Ozg8KOCGQcSeX6eEbzijwARSx z87SBGzgQXrJgmQj4y9rqahJIi2/IfHXQYnTQqrSH3YuHykxWks7vY13OEHhFvD8vGPPZacSl 0vh4/BxR+h3Rg2NezAONCzdzD2h76e/POFYQxCL5rw7uefwZN/Q1nhHbx1+riCV3XhCT/IgSs z3Hf0qc5eLve/51Oxl9nyxnggaP4dLN9SArkHl3i7wybj7aMTlxpOaojQCxLGs2BH20fu5D/G eAKtq9EFkRWuoBjZQ+bbDoFgEhT8OiNnqv0p9ejUWGPpC7U8Dh58pNrpLJiLur4UA5id/Mw7T oKP7Mf/Vt93TN7hTMXKUDchonhdM+3mugMAQDLpS6N9w3gqQ8eeHYb2pLDXtTxo6xvmGx9GqU sPcpntjDKZEM/KvbCl1glNpHpLMl3MzRI+qVnWIgTQQTQnXnBAVvpFJyRVWc0RMM140CZ646H Ce/6bRuU9HGf6Aj8pAImgC5DA0+G07Zq2omhPrK9IfBeYAghvxUU2Ao782KBJgs0kKGCF6/U/ jEo5EFT1Y/fM/BjCS8ejFX6yiC6eTnZNdxRq0Xf4ub07t7ptNgye90jItGqhLGZgA5lolXrSD PSJA2XzZF42SI6LXSJDoTW8pIAtqGrriVJmS5xjMp29Ftm0e1j70v0egG8CV+3DHnFJ7nFrC1 dXVEtQ== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240117_094157_682746_2408B19A X-CRM114-Status: GOOD ( 11.08 ) 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: Markus Elfring Date: Wed, 17 Jan 2024 18:06:55 +0100 The result from a call of the function “kasprintf” was passed to a subsequent function call without checking for a null pointer before (according to a memory allocation failure). This issue was detected by using the Coccinelle software. Thus return directly after a failed kasprintf() call. Fixes: 1b2189f3aa50b ("clk: versatile: clk-icst: Ensure clock names are unique") Signed-off-by: Markus Elfring --- drivers/clk/versatile/clk-icst.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.43.0 diff --git a/drivers/clk/versatile/clk-icst.c b/drivers/clk/versatile/clk-icst.c index d5cb372f0901..c4cf50a48972 100644 --- a/drivers/clk/versatile/clk-icst.c +++ b/drivers/clk/versatile/clk-icst.c @@ -537,10 +537,12 @@ static void __init of_syscon_icst_setup(struct device_node *np) return; } - /* Parent clock name is not the same as node parent */ - parent_name = of_clk_get_parent_name(np, 0); name = kasprintf(GFP_KERNEL, "%pOFP", np); + if (!name) + return; + /* Parent clock name is not the same as node parent */ + parent_name = of_clk_get_parent_name(np, 0); regclk = icst_clk_setup(NULL, &icst_desc, name, parent_name, map, ctype); if (IS_ERR(regclk)) { pr_err("error setting up syscon ICST clock %s\n", name); From patchwork Wed Jan 17 17:42:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Elfring X-Patchwork-Id: 13522060 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 665B1C47258 for ; Wed, 17 Jan 2024 17:43:31 +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:In-Reply-To:References:Cc:To:From: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=N08wcZHRr80RWRuussn73AyvlWp+4RJPIZxfibJGtcc=; b=wEHriu+DfiqQeD AmPpBBlCMFXThff9plXxLhd5DxM0wRZgnbjkGP33gJEJ8CmOEs+EGlUSnDCUCeQjaUJ45UCXmoaOg cdda5ccrcjTAcFpD5kmUFngNAKBxva+Vhhkq+EKN0qJm+cnqoNHn5q0miS9c59ga8T9Qsx8QnnssM vsRWDFDzphEy/MTAoW9c1Anc4zFC7Q47D3eqYPibqj7sjXuSSlt3FWzdtq2TxkGZ/IyLtyGwoMBKV n7uwPSsWknAcgHu6AHjlXdi4SU5kaUIer6lGbmcByZ4ymzPbqi6X5SXcQ18OXp7mA6PRxWXrlIvuG Gv0s8Eap4uZYbkKhFkTQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQ9wQ-000GIc-2R; Wed, 17 Jan 2024 17:43:06 +0000 Received: from mout.web.de ([212.227.17.12]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rQ9wO-000GI1-1R for linux-arm-kernel@lists.infradead.org; Wed, 17 Jan 2024 17:43:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1705513378; x=1706118178; i=markus.elfring@web.de; bh=f6I4pFBn++drw1Q2ezqkh1AqMCsZ2H2H4yM4gd4p58w=; h=X-UI-Sender-Class:Date:Subject:From:To:Cc:References: In-Reply-To; b=A0YokYBu98xu8huJjJ+zxxJUHL3hL+dnWJHMSkWCP6voo69bWzijUh/J31vmy7c3 tejAVjUEcEt7JI9CRNGzX5H3FGD0WxKP5W91tX3izfON4Mn9hE39fVEPAnwXmK31I I7SyyeJZv5XgGOM4orZSJzcd6P50r9pU8QzRIxaiA0Hdp8EpW24RpwDzs/p9upKwZ IlUYAFtIdi68W7R+aDVhwlCQmFYRna6KPDaH6778oj8hEW4HspT9/BuY+HLV64EHS 5pSuK1975H+QN/0+IEPFqS+LxMP96KCg0ebtP49kQ2gNU3YttKgsL2KIEgCHYOGCi ra+atHlqkteErpg/WA== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.84.95]) by smtp.web.de (mrweb106 [213.165.67.124]) with ESMTPSA (Nemesis) id 1MZSFY-1rf6Jw0uN4-00Wf5C; Wed, 17 Jan 2024 18:42:58 +0100 Message-ID: <22084283-6854-41f9-b45a-4b27ce207f76@web.de> Date: Wed, 17 Jan 2024 18:42:57 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 2/2] clk: versatile: clk-icst: Use common error handling code in icst_clk_setup() Content-Language: en-GB From: Markus Elfring To: linux-clk@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Linus Walleij , Michael Turquette , Rob Herring , Stephen Boyd Cc: LKML , Kunwu Chan References: <061aef8b-a41f-4346-af6e-560c7594b27b@web.de> In-Reply-To: <061aef8b-a41f-4346-af6e-560c7594b27b@web.de> X-Provags-ID: V03:K1:Rip5RFA4nXZcm5gpQQi9JPsjHk1zDHBzC8eEQi7J72jEZipkAfz DzVpUfkR4ZqAsD6rUWRMyM1WO53ZDGl7hgEUiQrSYKaAmpqZpBST4E1tn+/U+B2PVijfBkp 1qgBmsSeyMinqTiysU2UuU1uFo6gXTYP4i2DIsEUGbuh2YJEuEXbJxX+Vs9HVlA4LDrj9mU LP5Fy3Jzu3YYKaVZ28v6g== UI-OutboundReport: notjunk:1;M01:P0:fAHvs1aGqkk=;rN+3696c0VFb7jWKXBuvwLNtspy qxckwuivcuutKifP9gz+fzwRBOCors4B9h0HWryqR/DaeU0WMicW7cK9UT2rI4peXkzBILUyq Hw+UR2S4CqiF8i58TLYOO8jVh5z5mrpknoIeNHNMWSb1aOTbTfz8U2aqZKnt9qcZP9+Sx7hsx KZ1K+qk9PiRHptCPm5GK483R6qmVlR1XcNJqMfBlx47Ca+Gz30xhgY5YNTWg69z5l45fOK7Fz 0RtMtycOgro1TgkRLaLBvOjIhlVmwk/T+1LZBRgw5aNAll/3/VH5oKhSkchi+EBvT/ku3m2ht TBccrI0wW6qSRopiEl52aF4N+lIWbiY7Wi7K17dwAyLIxPD/KhdCfdM7jFXnSEwY9/v1MsLqt h6/lFJ6+V1Gkzd2r095xWsS+w2YvUZNSIomjsZ8qKQSGziLPzFY1SPXXlg8c8clkYRhyqtjEn 3mMJmLSx41VIOwiOuNRrtcX/tdDuX8f4AHikdtSrzsfzeLkTN1R3xq9V/ANguPDU6jLDY4d5h caVtVgkBhO/urfiuQlW2MIHac2gJc2qc3rCt+Wc/eXZTlZq6dkqQx6nKyy3Jy8VrZvJ14AXBN 32rzbYzHmmBYZvWMupAe2kYGWjnfuHztwTMC1yG5B12PKnGGIjgdikNdVNibr3zRvoedZc12G OOJ0umK2OP6vnVpOLZQzh07Y87bs7JYlGkDxqZbYDq7tVbHKyeAX3F+FB70jctqT+osJQkBdG PCtMQjS+Hf9HlmHJZCPIVW901dCEe1zW2RU/sjlCw4SwqWXdlTLYNXZWeNCl5nr7MJ46XOkf/ q1SYJXenSRc7EM12Htz98QfG7qGdUjsZbJ2jJCRVcPjQYwWoLFBYyZ+73LVYXu9AjM6o4O+cM HgDMKgdvS2F/qBoIAph1SPGq3xaUmL7RfEW1i+wLk/Hs/Rx7eH3pqFwuMWKCOQEal1JowcuEC huKtOQ== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240117_094304_780002_5F44D436 X-CRM114-Status: UNSURE ( 9.39 ) X-CRM114-Notice: Please train this message. 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: Markus Elfring Date: Wed, 17 Jan 2024 18:18:25 +0100 Add a jump target so that a bit of exception handling can be better reused in an if branch of this function. Signed-off-by: Markus Elfring --- drivers/clk/versatile/clk-icst.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- 2.43.0 diff --git a/drivers/clk/versatile/clk-icst.c b/drivers/clk/versatile/clk-icst.c index c4cf50a48972..9957dc9b8941 100644 --- a/drivers/clk/versatile/clk-icst.c +++ b/drivers/clk/versatile/clk-icst.c @@ -351,8 +351,8 @@ struct clk *icst_clk_setup(struct device *dev, pclone = kmemdup(desc->params, sizeof(*pclone), GFP_KERNEL); if (!pclone) { - kfree(icst); - return ERR_PTR(-ENOMEM); + clk = ERR_PTR(-ENOMEM); + goto free_icst; } init.name = name; @@ -370,6 +370,7 @@ struct clk *icst_clk_setup(struct device *dev, clk = clk_register(dev, &icst->hw); if (IS_ERR(clk)) { kfree(pclone); +free_icst: kfree(icst); }