From patchwork Sun Nov 13 18:11:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2489 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 33C3D40F5A for ; Sun, 13 Nov 2022 19:11:55 +0100 (CET) Received: by mail-ed1-f71.google.com with SMTP id z15-20020a05640240cf00b00461b253c220sf6762390edb.3 for ; Sun, 13 Nov 2022 10:11:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668363115; cv=pass; d=google.com; s=arc-20160816; b=s3VeL5+Fm2RHSnO1Kr0/NSDUaWWhm2eLJP44sseg8Wy2/hYcu57XCxCXujkS2cGzba dbr3wI4jbI/GarMukTk9SNWtaZnowI27wLGyEzTPq2+urOnBVr/LAewvXkOZ/T4HDKE/ tIYGUenlFpMB+a4kj1AAKrB4dQVxnuCAJQ61NWlxmRcEsIvmVomuoh2fAefkJT/+hkpU KSGaDaVbMxk5FV09DcEi6Y3R3znfvmDllx9nWNX91VJCntCWbC8r+chOtljQ0teJE33C 6Dx1En1dEQnJD4r5xjw2VT+QAcX1khDwnMW7LNVd6w3y9NSLgYIKBCbMpGyMw/ADDrvx vrQg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=toQV0BTlG7cW5KXdjECRy68+DDE6N9BtNWQman32k8Q=; b=F4rs8q22mM5DkQYTEFRLsk1hfjyJ76OJ5rT+pxHiOco9Azmyl/c5gJZyONwczqFL8E 7BqaFRJfscd7KTqXJTNT2NPbPet/OG/snWPynhBoxCFkvmeVfJKAASJI7wRD8gen+ZSv Q8JJd2cr98DhMH60WO777g/MWqTsM2y85F9L0C8Sel2z4OQ5jv1KvswVUsbOXZN6X6wL DVu+EzCB0K3fJ7YX+kaYCknnJfNIQLfYfpXupmdsOOh31zhz7CxR8vAymEozxkHNWuTQ Ov+SJKiDVhka7+fklURnzrpxnLItzDsxRMFC73jASsK5XY97Ucljs01pKYqLT63lqKss z8sg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ZeE7sehy; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=toQV0BTlG7cW5KXdjECRy68+DDE6N9BtNWQman32k8Q=; b=LudeE4nxSYuO950YlOL2aaFIVEwV4cH9IMdPStTOSdzGsoFgU1VPxHnpnxhzDJTCdq oKEd9ilsLMYjt9CzdzM4hh34fnF+G/9PLCIMpOfHpWe0vYByyhqTivy1Kbmc89p9Ojn6 OwXv8uQX+WtgwTKc+vi6spQxEr/F4LEvtYjnE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=toQV0BTlG7cW5KXdjECRy68+DDE6N9BtNWQman32k8Q=; b=3A4YzFratxctxvLU33A6MKnH+RvUtoKkevNj69ot6voTL2iLZcwn6FDj0FHKqDbS6n cUHgSqFPcnYc5vFQ7KWJzmQCzdMQBPiBGmNOpZHuEyVuryvelQRWbLUmMPG4RIUokVnj gBA7j6y57FeEGyCCzF9PJvOmQuNxHsqfFEtoU+o87kEV18w6YT4e/UOcOeRLxcuuL7Bv 1/RegV00GsTwGmrvJ6mw+Cp1fyMPcGfbrx/Lk8kc52JYE1ecpG65kjh6wwrb+qrk9BMN PmxfKTYwnqAeoHX8OX3Blr9ARNmrDo3QX7kEfYTtsAHQVUighY4zVsq+R7KGzO5l742M JYDw== X-Gm-Message-State: ANoB5pky1UV0ucnX6HABp+YTrdAzOHiFOEDgnDOeLNKITaMHVbSVSZ3C bDhq5F5pdsMPH04nnOUHrRDt1K9v X-Google-Smtp-Source: AA0mqf51p6yY3kYbUQpK83VWAY+wrwkbSkQmsbQSetM36zZHuCCu0gssDU+s8hQ6eBNj33JkEhml5g== X-Received: by 2002:a17:906:a884:b0:778:d81d:b1f0 with SMTP id ha4-20020a170906a88400b00778d81db1f0mr7904627ejb.731.1668363114811; Sun, 13 Nov 2022 10:11:54 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:2708:b0:457:99eb:cba9 with SMTP id y8-20020a056402270800b0045799ebcba9ls2530229edd.0.-pod-prod-gmail; Sun, 13 Nov 2022 10:11:53 -0800 (PST) X-Received: by 2002:a05:6402:1495:b0:461:b506:6b8a with SMTP id e21-20020a056402149500b00461b5066b8amr8720176edv.208.1668363113666; Sun, 13 Nov 2022 10:11:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668363113; cv=none; d=google.com; s=arc-20160816; b=L4Iv9UaEbK4yHbHn7svU/i/8hUzD+qlFjVI3NDhssqlIAx6lmg7xTBY9DtuL8GTacy 7JgnZEHVsfaQSX+ntCNXgoK0oulUNggS9llUKREK3brPz/7PuEMBAfk6BY6vz7CNvJa4 FNeVbe2wCLCGsSw/7sqXyCdk5Li69rqhrFqiPvNFwA3jluKdNasOYWaIdtXST6D7bg0B v1Wd0aPwLhDEhVqzsewmwjK/n+g6U68raPH18pLGlfK6/oNPB1RRkvZtMu30RZrriFC9 H7zbK7swPwdtXBJBGVkMjVyv+aMrL44Z7Z1Nwz4sixgFCwpAlsFWsNKNIhGsF1xXSMWh anIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=uVJeOgU1MIdsaRRuNRXfWkoor1WXWdAlm1t56aPqLUQ=; b=CS2cokTBBawbkg93FUqJaZ08MhyRQ6GOr88UALj6wdEXhdpX22LqXgVsDhrS7qez0P c+f5LmkQjUNPP6EgKAPoIdXBrID5oNGaxoLcB6eI7RwMWIQpf7+9hG+bX2tBCrwGUIHL UJj7EXUUhaO251v3ydWGTkZ9KuKDnye3KEXR8j9KaH+wdLdPXPRSnJZ+i03tBiOyFaEv ywdYAKO64dYWOsynaDazwTNn6WX2GjkRAoXv67iIADi5xbXJlyv/BkdE97lnUOqSis15 iko9kMWmgjlHgA+/t0mVp8FaoPRdOoTR1lgQwAiYrF1QtWMo2OYlc0O80fombhMtSxMT rEqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ZeE7sehy; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id m5-20020a50cc05000000b00456ea7cddbbsor3715961edi.24.2022.11.13.10.11.53 for (Google Transport Security); Sun, 13 Nov 2022 10:11:53 -0800 (PST) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a05:6402:291e:b0:45c:98a9:7bbf with SMTP id ee30-20020a056402291e00b0045c98a97bbfmr8617406edb.372.1668363113421; Sun, 13 Nov 2022 10:11:53 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-79-40-103-33.business.telecomitalia.it. [79.40.103.33]) by smtp.gmail.com with ESMTPSA id i20-20020a50fd14000000b004618a89d273sm3753534eds.36.2022.11.13.10.11.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Nov 2022 10:11:53 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Amarula patchwork , michael@amarulasolutions.com, Dario Binacchi , kernel test robot , Allison Randal , Miaoqian Lin , Michael Turquette , Stephen Boyd , Tero Kristo , Thomas Gleixner , Tony Lindgren , linux-clk@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH v4 2/2] clk: ti: dra7-atl: don't allocate `parent_names' variable Date: Sun, 13 Nov 2022 19:11:47 +0100 Message-Id: <20221113181147.1626585-2-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221113181147.1626585-1-dario.binacchi@amarulasolutions.com> References: <20221113181147.1626585-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ZeE7sehy; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The `parent_names' variable was freed also in case of kzalloc() error. Instead of modifying the code to perform a proper memory release, I decided to fix the bug by not allocating memory. Since only one parent name is referenced, it is not necessary to allocate this variable at runtime and therefore you can avoid calling the kzalloc() function. This simplifies the code (even calls to kfree can be removed) and improves the performance of the routine. Signed-off-by: Dario Binacchi Reported-by: kernel test robot --- (no changes since v3) Changes in v3: - Add the "clk: ti: add of_ti_clk_register() helper" patch to the series. - Use a variable of type struct clk_parent_data to furthermore simplify the code. - Update the commit message. Changes in v2: - Fix compiling error - Add kernel test robot's Reported-by tag. drivers/clk/ti/clk-dra7-atl.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/clk/ti/clk-dra7-atl.c b/drivers/clk/ti/clk-dra7-atl.c index 1c576599f6db..d964e3affd42 100644 --- a/drivers/clk/ti/clk-dra7-atl.c +++ b/drivers/clk/ti/clk-dra7-atl.c @@ -163,8 +163,8 @@ static const struct clk_ops atl_clk_ops = { static void __init of_dra7_atl_clock_setup(struct device_node *node) { struct dra7_atl_desc *clk_hw = NULL; + struct clk_parent_data pdata = { .index = 0 }; struct clk_init_data init = { NULL }; - const char **parent_names = NULL; const char *name; struct clk *clk; @@ -188,24 +188,14 @@ static void __init of_dra7_atl_clock_setup(struct device_node *node) goto cleanup; } - parent_names = kzalloc(sizeof(char *), GFP_KERNEL); - - if (!parent_names) - goto cleanup; - - parent_names[0] = of_clk_get_parent_name(node, 0); - - init.parent_names = parent_names; - + init.parent_data = &pdata; clk = of_ti_clk_register(node, &clk_hw->hw, name); if (!IS_ERR(clk)) { of_clk_add_provider(node, of_clk_src_simple_get, clk); - kfree(parent_names); return; } cleanup: - kfree(parent_names); kfree(clk_hw); } CLK_OF_DECLARE(dra7_atl_clock, "ti,dra7-atl-clock", of_dra7_atl_clock_setup);