From patchwork Sat Mar 25 14:05:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Elfring X-Patchwork-Id: 13187781 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 4F33AC6FD1C for ; Sat, 25 Mar 2023 14:06:29 +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=0w7iqMecRplQSX9OAwRmh/Ofs56UPnZJmEh6q6iRPNg=; b=g4aMlup/W60uOS J/OGaJDInJ61qqdVMlrXaQtS1aZSA2V5QjDcXxCKVbxOOgmFC1ZkiTv/Gc7WzLcWyAoYQdUJGrZY2 Oz/CIIpOvrVCj4C7bRu4pOjd97yQyoGoh1BIUapg+SJRazOnmuXZfVaDm67TA+VwJP7HOxeg+Frrl xKhyukXYMye7NfBFA0cxeO3DW+1WZIA4kJoHtWy9nZdm9meydPc0Ex3p9WAC5GzQ9KIV1OCSewMI0 uN+kAMWZqaXAJ4y+O91A+cHytIRIzu9PFFMjP076Xn4VEVLH524UkrUbP60FGj/On4uPyri/i7TkD 52btrcHVTIhs70r07E9Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pg4WK-006niO-0c; Sat, 25 Mar 2023 14:05:24 +0000 Received: from mout.web.de ([212.227.15.4]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pg4WG-006nhk-1I for linux-arm-kernel@lists.infradead.org; Sat, 25 Mar 2023 14:05:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1679753111; i=markus.elfring@web.de; bh=7sqfY1AC0lxmDISvcZR/B1nVQ2OCqHB3UuwFODLG3o8=; h=X-UI-Sender-Class:Date:Subject:From:To:Cc:References:In-Reply-To; b=D9crxBSSLpW4R479Lkr6agkDrGVp600WFn3S+UFtTeh/OmsHh+FyQSHm/IXIHSv4N xLVYcu0jMee9Pt31Z+H7SNr3zoEw/IcbvU5U2BLO97CVAsd7Z+tWDV5TCmpnY6uEDK E9FFMM6J7MjJ5p+3y8h5uZP+O7pb+ehmai3llXr+lwLCIuymjEKpSnC4JecPlg0fsK JFURL52RlkQHVdwr9INwMQvdqDEIZ7uYCisb9J08c1qK6KYvcmA2dXbIC6V4oJgiXx u3fdCyCbkAav0xjRYbSmLqPQz2BbjvcWsdhw3B44RAdQl3rG1awisOu+gYZcsXyorL iTj8W20+Zizrw== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.81.83]) by smtp.web.de (mrweb006 [213.165.67.108]) with ESMTPSA (Nemesis) id 1Mrwrx-1qIeKQ1WDN-00nyAl; Sat, 25 Mar 2023 15:05:11 +0100 Message-ID: <9e3705dc-7a70-c584-916e-ae582c7667b6@web.de> Date: Sat, 25 Mar 2023 15:05:10 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: [PATCH resent] clk: at91: sama7g5: Add two jump labels in sama7g5_pmc_setup() Content-Language: en-GB From: Markus Elfring To: kernel-janitors@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Alexandre Belloni , Claudiu Beznea , Michael Turquette , Nicolas Ferre , Stephen Boyd Cc: cocci@inria.fr, LKML References: <5ed1bc78-77a1-8eb8-43f9-6005d7de49c8@web.de> In-Reply-To: <5ed1bc78-77a1-8eb8-43f9-6005d7de49c8@web.de> X-Provags-ID: V03:K1:hlQ92EaiJHlztMXECQzhYQuLvPvUT72QgaUpxu0Yo0QtefrrZ4S 7sBEBaKGb/GtREncIARiyW9xlKunc+oG+ytgc7JRNFvaTtfnmgfG+XY9Y0OiuQn8j8FaK+N OfsZ8CWUdp1SBp6s09VjWyM7k+0zjc2nNNPS8DusTWdMoHX6HO+PCXhm4LudcXUMgUnacrn xK2UZXCfRIzmr9KziwHqQ== UI-OutboundReport: notjunk:1;M01:P0:0p2joeq4bjs=;KskENKywRzsfH8cZV9VPn03EtPU Zd/nyWdQXq4JB+BtZPGL9Dj2JZMvKWb2dK81DqjGdXhXXDgBqNIiYQI5frghmUbG9rxvXGWlp aM2GYFrrvYrlImjKuEZnEeIZWeiVWYbuYvkG43bojDNt00SCuzXK2HRSZicv4fIZeE8G8yBFS jT+MzEW4nR5th4jne7AC8ktr/eYZIqGb6HlqZTp/BFgBBN8HoigXGl9jPQPtJX9XUqA3WLDYm w+iB/u6rUSzwJUfFLIiesY4/y/6l1lF9gLsdBQalznkLib2HhSSv5apTk1t48pJGrAwIS0k9C viy4z+7FY/xnhbZtBTjyT8b0dt6WQYseAKaskrHNJQehfKmUvySy8DGdIDyNFhjKu1HVYUNf3 D7KF4PzpsRt38H0kqrdafFHkO7G8svcx5YodbIS1yIfYR/z0OLvV4kSPKeZY+/VjHdVBrGGmX o57U3oXWgqcUjBr6zpq4q1oQCzoQrK/XQrWPsX3hsVc9VGjbFJ96Jl0VDNKnBPyVVcTx+S6sG VNuwScItfSaN3Q7Rmw67kNMklVQAx/pVQeSbHciJgJY7pCITq93uKCoNfVnXO3mmz9FWSQMo8 /I118e1H5B480s/kYAO3/AK7rf6NhUBHv1rq6oQBg71wnsylKFMrlg4cn73mfMAAExlaDLzZk 8bjqgeWRK9rFUcbZ3hfbSiGqCxB8L8l3d+D/H/Kv6FirSf8jIRkikQVBwrRAkeOw8d8VSpNVn nqKtPwDhW1a6cQISHj8LIkghTle7nV7AvZMPT/OXKpkCOgHCw6NRJrFcyz/naAb9VLEZ6vQrM QGfpo0NDFkW0/7rFo1nxVD6H3/5LZ/ZuSPkg7qwxrowX0vuRnKkbscEPrOmCKBJy0tQUij/Vl pADbOXRUuV0JBnOjSqkd54ntRW/sqWdF3PMECg9RXZhwZ6D5K5AzXcyGj X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230325_070520_760033_DF0559A9 X-CRM114-Status: GOOD ( 13.60 ) 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 Date: Fri, 17 Mar 2023 20:02:34 +0100 The label “err_free” was used to jump to another pointer check despite of the detail in the implementation of the function “sama7g5_pmc_setup” that it was determined already that the corresponding variable contained a null pointer (because of a failed memory allocation). * Thus use additional labels. * Delete an extra pointer check at the end which became unnecessary with this refactoring. This issue was detected by using the Coccinelle software. Fixes: cb783bbbcf54c36256006895c215e86c5e7266d8 ("clk: at91: sama7g5: add clock support for sama7g5") Signed-off-by: Markus Elfring --- drivers/clk/at91/sama7g5.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) -- 2.40.0 diff --git a/drivers/clk/at91/sama7g5.c b/drivers/clk/at91/sama7g5.c index f135b662f1ff..224b1f2ebef2 100644 --- a/drivers/clk/at91/sama7g5.c +++ b/drivers/clk/at91/sama7g5.c @@ -927,25 +927,25 @@ static void __init sama7g5_pmc_setup(struct device_node *np) (ARRAY_SIZE(sama7g5_mckx) + ARRAY_SIZE(sama7g5_gck)), GFP_KERNEL); if (!alloc_mem) - goto err_free; + goto free_pmc; hw = at91_clk_register_main_rc_osc(regmap, "main_rc_osc", 12000000, 50000000); if (IS_ERR(hw)) - goto err_free; + goto free_alloc_mem; bypass = of_property_read_bool(np, "atmel,osc-bypass"); hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name, bypass); if (IS_ERR(hw)) - goto err_free; + goto free_alloc_mem; parent_names[0] = "main_rc_osc"; parent_names[1] = "main_osc"; hw = at91_clk_register_sam9x5_main(regmap, "mainck", parent_names, 2); if (IS_ERR(hw)) - goto err_free; + goto free_alloc_mem; sama7g5_pmc->chws[PMC_MAIN] = hw; @@ -987,7 +987,7 @@ static void __init sama7g5_pmc_setup(struct device_node *np) } if (IS_ERR(hw)) - goto err_free; + goto free_alloc_mem; if (sama7g5_plls[i][j].eid) sama7g5_pmc->chws[sama7g5_plls[i][j].eid] = hw; @@ -999,7 +999,7 @@ static void __init sama7g5_pmc_setup(struct device_node *np) &mck0_layout, &mck0_characteristics, &pmc_mck0_lock, CLK_GET_RATE_NOCACHE, 5); if (IS_ERR(hw)) - goto err_free; + goto free_alloc_mem; sama7g5_pmc->chws[PMC_MCK] = hw; @@ -1128,12 +1128,11 @@ static void __init sama7g5_pmc_setup(struct device_node *np) return; err_free: - if (alloc_mem) { - for (i = 0; i < alloc_mem_size; i++) - kfree(alloc_mem[i]); - kfree(alloc_mem); - } - + for (i = 0; i < alloc_mem_size; i++) + kfree(alloc_mem[i]); +free_alloc_mem: + kfree(alloc_mem); +free_pmc: kfree(sama7g5_pmc); }