Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp1942483rdb; Sun, 24 Dec 2023 08:37:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IH4ReuReM/+wZ+IPmfFsfONl2cpUHBMrNApdqKs+MgPo7MIr0JXnr3b51CD5SwYeRKpRx6l X-Received: by 2002:a05:6a20:3d1a:b0:18f:97c:384e with SMTP id y26-20020a056a203d1a00b0018f097c384emr5554033pzi.40.1703435860627; Sun, 24 Dec 2023 08:37:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703435860; cv=none; d=google.com; s=arc-20160816; b=nX+L6WSSHsXYqW4VD0aUIOdxoSi4CsLSfMfLrNgvQpSZAJiAlhe5v+dimpEsHE6KQ3 yZRRQst6njXcGL7rokQOvC9mW/7s4enhksg8IdBElXpFh66GV6tOoc/Zn7OU+58t/ocj ZCQ2ACr4RXaT1q1VK9+sS7QKleAqgK8ainMa29IRotsiMmCCSEgX+VB0VyWomgoDwbVk 2RPKYp5YsSIq5iavM6VOStiMuEhVWNmaR0CJB7FqlWGBRSu8E58nPSNo+DOJY9oniJ+g a148zcSiry154RZPRkhmdygjacvTapz1yicyVU3J1U6XjtK51I0VDUhyuGsh6givIU5S MRvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=T9u4solGEcwZXbgSKeafa5rI8oOhRUXkZHPfzeeWl68=; fh=sjHIukpoR7qU1+33gpK0xo2A7Js9I7GnF+G77h/eU8w=; b=0ovNSNEr49nwDIPvtw/gVrjldVaNVqkFo3AaxnRwrJnC4jCREz4zh25q3MLvYKEDjN yw9z/t78Yu/BtEG4bO23V7uIqLy5gxgN1rIgS460cxC89hlkkwzK2Ftnr6VplsEHZSrk i4Zid+A6AFzXemNbP5Bgx5sDXA1QY2h+DPZGPixRZc4b6iPEM7uNv+RE4wt10/IDgCNU bTxLuhZi4N5AyHZnT1wYVmcCydqZxb59VbHXFYjpe92VvWxuqVr9zeVK/wymaSaa5B9e 9cFxFiqxV15unkXHGYweHwrRoMPWWn9u4MNNJGvIkN2jwiqBjftQ3WSQbq3S6qxH4xto rYBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@web.de header.s=s29768273 header.b=d2btJZgB; spf=pass (google.com: domain of linux-kernel+bounces-10760-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10760-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=web.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id f17-20020a056a00229100b006d2fd72b33fsi6754783pfe.282.2023.12.24.08.37.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 08:37:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10760-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@web.de header.s=s29768273 header.b=d2btJZgB; spf=pass (google.com: domain of linux-kernel+bounces-10760-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10760-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=web.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 2B81FB2140F for ; Sun, 24 Dec 2023 16:37:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3DF07CA69; Sun, 24 Dec 2023 16:37:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=web.de header.i=markus.elfring@web.de header.b="d2btJZgB" X-Original-To: linux-kernel@vger.kernel.org Received: from mout.web.de (mout.web.de [212.227.15.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 71608747F; Sun, 24 Dec 2023 16:37:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=web.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1703435819; x=1704040619; i=markus.elfring@web.de; bh=HUtTyqgAjeXilij1EZvW9BI8jaGz1KwDa0ackvdaMP0=; h=X-UI-Sender-Class:Date:Subject:From:To:Cc:References: In-Reply-To; b=d2btJZgBjrL9shctEps3kZP6ar2tniPSbSRCDxu5GQKJuq9gCNGhMqPt2GrvewjQ 3IDdl8d6sMRsR6RugTGpDyuJ8Ny54xfbFq/osyKsFMDoqUGOqMivCT5iVw/Z8zHCR FCBCHvRnPw6aZ8gdXOOdq/roceRzdW8gN0OxeLcSmzHjeVHdzJjWpkmJTlcvrkJM1 MpXaBo0FyGv+8i8VfajSsWx2eCa3MqO94+K6TqEQTinPg0c5MvzpFCSjZwzwGuiIN inQVAyjI0MEE+/MMujKR5HtPxyygugniPGRUwm672dw+rBdOc8rF7ZR+FrPj1pkmA 1wzR9sjG78uxX4Lm9A== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.85.95]) by smtp.web.de (mrweb006 [213.165.67.108]) with ESMTPSA (Nemesis) id 1M6HKG-1rJcGY3hhQ-0070lV; Sun, 24 Dec 2023 17:36:58 +0100 Message-ID: <422c6249-31ac-410e-911d-ec25aeee126a@web.de> Date: Sun, 24 Dec 2023 17:36:57 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 01/10] clk: ti: Less function calls in of_omap2_apll_setup() after error detection Content-Language: en-GB From: Markus Elfring To: linux-omap@vger.kernel.org, linux-clk@vger.kernel.org, kernel-janitors@vger.kernel.org, Andy Shevchenko , Claudiu Beznea , Michael Turquette , Rob Herring , Stephen Boyd , Tero Kristo , Tony Lindgren Cc: LKML , cocci@inria.fr References: <20849a8e-e0f5-46df-ad8a-9eae6cbe337b@web.de> In-Reply-To: <20849a8e-e0f5-46df-ad8a-9eae6cbe337b@web.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:5Zlu4vBjOn8y3rhK/v7xJFB3kzVjuBnaLVTVepoXE3uf2IfFtqB 6rHVkvjJnEO9/UjDh4AgBecn1KYpjrdkyYpVByNrgF+lPLy6EhBHUwttNktZ3HbbeWAY2WZ ynEcS9grOUky6y9Lp7PKZHfuvoi7y2yUIAbBhDW+E2l1Vsw6ZCmN0SawMeLTX7aaB1iirtb IJSPvsHD6I4Ry1wVjcZig== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:iocNUSrfeNw=;wYkjPLwi2LIAvzmFQCTm/TVNKNP dySDCNs/XyI8mriI9wR/iF0jYz36JlM7n4uOAlurxXlRCek9gBOiFIB4DPPXou0jXevH3ao4E Xf1u50XGvq8y7rjPJkSoJ6d+LELHTsmWYthxYMkHtBxRq/ANC3OCHy0uAI+RuuTCGORLDGLxo dZ3pJYhcbIMIGaU0w8sikQ/Fh10GhCu3FHR5XDP1O6zRs+K3O3zFk8z/YwEdMIowxBIWioBco DY6oUDExpJtAhyExNYuia88lcq3I+uUU2pVj2AM9iygDwQ2ZsdmgowuktDtsGzG0b/ZLADVUR QZWswuvVh7GXTGiukDJz3hIoW92R1dLQQc0fBB9r8VpzKustixfEIblNY/+oznttG0dHfvCRU ETRz2J3h0/pM/4RIZdfBRwwWnUCMZkGZcSeOpjVDYV5Dv/DT+cZ9gDNX5WPE3LyEXoVxP6ebp fVw8OKY74NAL5VJkUsUMpolCNOxhe/lJsHVtipS2CZV8A9nRMnTtzhsg5/IYdq5/X+W/H0uX1 CTEHoQGXbZn/QqUAtAcm2W53Kb2YBHP7pkaXEGiPzc7ibeEjEk55QYU0FUaF9Kxoy/05HGwVh R49G5+LYIIhoO2+YGY4pRkXqYBSHCgV+VWGu7Ht4yXCgEIYI+H/exhGOjbBzyJk6q8dwVgi+x 2CCEzxT0B+O1v0p+sCFqiV9+fEthbUCTUIVYUtokvxro/4N9Mcox1ArD0a1KEyBbrIt+HsB3D VKEhkDIMAHKCKSaa8Am/FZOL4kGUJ/lQTbrYrWqfi8MlrlOS1NW9XaxdmRHtuEWnXyaPAgrxQ //78P2kKxNwxGGT0YMqZtAh73NUtZHsHqpMvgqcRwav8/gHR2SpVtLojRZ26IslwieeL69c+f e1d8+55MqT1lMAqYo60S1ZZrJAIXHM01vDHTXOoyPnDUQpiJvuq6eJvU1jei1BFT+a/ShrKuM jrI4PA== From: Markus Elfring Date: Sun, 24 Dec 2023 11:15:27 +0100 The kfree() function was called in up to three cases by the of_omap2_apll_setup() function during error handling even if the passed variable contained a null pointer. This issue was detected by using the Coccinelle software. * Split a condition check. * Adjust jump targets. * Delete three initialisations which became unnecessary with this refactoring. Signed-off-by: Markus Elfring =2D-- drivers/clk/ti/apll.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/clk/ti/apll.c b/drivers/clk/ti/apll.c index 93183287c58d..929c021f0cdb 100644 =2D-- a/drivers/clk/ti/apll.c +++ b/drivers/clk/ti/apll.c @@ -338,21 +338,25 @@ static const struct clk_hw_omap_ops omap2_apll_hwops= =3D { static void __init of_omap2_apll_setup(struct device_node *node) { - struct dpll_data *ad =3D NULL; - struct clk_hw_omap *clk_hw =3D NULL; - struct clk_init_data *init =3D NULL; + struct dpll_data *ad; + struct clk_hw_omap *clk_hw; + struct clk_init_data *init =3D kzalloc(sizeof(*init), GFP_KERNEL); const char *name; struct clk *clk; const char *parent_name; u32 val; int ret; - ad =3D kzalloc(sizeof(*ad), GFP_KERNEL); + if (!init) + return; + clk_hw =3D kzalloc(sizeof(*clk_hw), GFP_KERNEL); - init =3D kzalloc(sizeof(*init), GFP_KERNEL); + if (!clk_hw) + goto free_init; - if (!ad || !clk_hw || !init) - goto cleanup; + ad =3D kzalloc(sizeof(*ad), GFP_KERNEL); + if (!ad) + goto free_clk_hw; clk_hw->dpll_data =3D ad; clk_hw->hw.init =3D init; @@ -403,12 +407,13 @@ static void __init of_omap2_apll_setup(struct device= _node *node) clk =3D of_ti_clk_register_omap_hw(node, &clk_hw->hw, name); if (!IS_ERR(clk)) { of_clk_add_provider(node, of_clk_src_simple_get, clk); - kfree(init); - return; + goto free_init; } cleanup: kfree(ad); +free_clk_hw: kfree(clk_hw); +free_init: kfree(init); } CLK_OF_DECLARE(omap2_apll_clock, "ti,omap2-apll-clock", =2D- 2.43.0