Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp444295rwb; Sun, 6 Nov 2022 08:13:44 -0800 (PST) X-Google-Smtp-Source: AMsMyM7eH0lh2q3oUMnInBnuuoVkB7+6q3+nsC6VxQOn+jXVMV/KsX7vDPi6VXYhrtMSS2WGYUxx X-Received: by 2002:a17:902:7d87:b0:17f:9cd0:2e03 with SMTP id a7-20020a1709027d8700b0017f9cd02e03mr46019299plm.164.1667751224628; Sun, 06 Nov 2022 08:13:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667751224; cv=none; d=google.com; s=arc-20160816; b=H4dJkd8E+hiaQRAqFBHnBLqegnUO5mhvYkNfJk9K53s9yxn6w2nf1pr8BU8gmqpfp9 q/YYu3diqMT+kVyBdosruWOwNJnvniGA3T0hlsk45P8BalyKJaSmVk0ZVPOP2+37NhTo BzrFC4jWblO88h6qymdaPNUpjn4NtN/ShP3jySlCKe9G2ZQV0N3mvn8wER+30Y6CVHI0 zzrSSleHGV1QorcPPU7XL0b8qn2PvLGCGczuzJAHBmAQmLR/zybVCWA9LyupDaClAkGV m/ABTZaV5KuvyYKImwuNUmuWRXKwBZppTVdoWA/uW01NZn3BYQ16cDl66uhdl/AOHktZ 69+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Ke2ic1RycAYFmZzx9qb25pQPIAwiVR4I1nr3ghBSQyY=; b=n4Xtv8u7YBVU6J72UsPO64uk1PsiD21zhY5fwTJq7S3p+Em6d05+h+H4KSbOkouIvT 4rNNM1Vyz6tCUXkXdBKgZOMCJlw9zg97axCVt9peitOC2jztzdjuEQPeJva074Q/BFQL X9nAKZaemY8T0F1v+ODPHew/e0c5kwZSf3zog3a/VZc9TpGmy0ktVyvwOJn4b74DFtJn G1VveX5bedr8luaKnDnXS44COa6wVrmaL7i14DQda/cznHsQRdSLhefT0dhcxXWEnki3 UqvVMMPiMPgb6mPBmXyy5WT6Q/quQ5qkWQFSE7KxrySTXQ/Sg5EuGTH0NEUMF/Gaqxcq q6Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ho8Jqqap; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v27-20020a637a1b000000b00450200a1078si7202629pgc.853.2022.11.06.08.13.29; Sun, 06 Nov 2022 08:13:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ho8Jqqap; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230135AbiKFPqV (ORCPT + 96 others); Sun, 6 Nov 2022 10:46:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230083AbiKFPqU (ORCPT ); Sun, 6 Nov 2022 10:46:20 -0500 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19A21D2FF for ; Sun, 6 Nov 2022 07:46:19 -0800 (PST) Received: by mail-ed1-x52d.google.com with SMTP id 21so14135072edv.3 for ; Sun, 06 Nov 2022 07:46:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ke2ic1RycAYFmZzx9qb25pQPIAwiVR4I1nr3ghBSQyY=; b=ho8JqqapmwSd/RDkOkzpd8Jf/NHJqLUPMSZDjD/nKHvZyPLAr5SgVpldkBoqFvTwmz vHE6Nh/0pvRNYSredu41wnwnfFcib3U6Ui92jSPD+TD9uAESTgvwUL438Jo2nMAvocaI Yw/TUUtfGb3bYpOuMJLLCgHfXLiFyykCXX06s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding: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=Ke2ic1RycAYFmZzx9qb25pQPIAwiVR4I1nr3ghBSQyY=; b=2kHxQgMJ0//aaWHwZTv/hi3g0ZFEq11s7cClAyRD/XgpdVFhLnpDHVXFrKsmiVN3yr ZYKUSLa+vJVS+xxK3AJAVqki45aNsM1IkQz+IIEAjgfpGEi8601Nqssmh48bhQAy6ZK4 qDTpQlNaAzI9PC6gHjBqT6FqIvb+VNhy2v4vnozhzaC89dEBmTU3U3rNFIrwKzsROIoS H+OfTYgKq3YqGUXYJ0m1b2AlZKDuEhtbU19wHqjlIBd8D9cGfaZLq4A3+DChAHYrFUzE SvYA6sTb5+HD1t/H2nPt2eZfL3ekD06m43VYxbWChg8LfppCMVS97CXYSieasz5rw6n9 K0RA== X-Gm-Message-State: ACrzQf0+NHdITdFBQxxHdvr75ppI+xfeGDXjfD71F6YmZurJht647fKb sd/pXxXUAoBrRT8ANSz5IZqDXAM655694Q== X-Received: by 2002:a05:6402:1382:b0:464:1e50:1a41 with SMTP id b2-20020a056402138200b004641e501a41mr20978094edv.245.1667749577399; Sun, 06 Nov 2022 07:46:17 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-95-232-76-31.retail.telecomitalia.it. [95.232.76.31]) by smtp.gmail.com with ESMTPSA id kz20-20020a17090777d400b00772061034dbsm2204139ejc.182.2022.11.06.07.46.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Nov 2022 07:46:17 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: michael@amarulasolutions.com, Amarula patchwork , Dario Binacchi , kernel test robot , Allison Randal , Greg Kroah-Hartman , Miaoqian Lin , Michael Turquette , Stephen Boyd , Tero Kristo , Thomas Gleixner , Tony Lindgren , linux-clk@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH v3 2/2] clk: ti: dra7-atl: don't allocate `parent_names' variable Date: Sun, 6 Nov 2022 16:46:12 +0100 Message-Id: <20221106154612.3474940-2-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221106154612.3474940-1-dario.binacchi@amarulasolutions.com> References: <20221106154612.3474940-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/clk/ti/clk-dra7-atl.c b/drivers/clk/ti/clk-dra7-atl.c index ff4d6a951681..373561626ec4 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,15 @@ 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; - - clk = ti_clk_register(NULL, &clk_hw->hw, name); + 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); -- 2.32.0