From patchwork Sun Nov 6 15:46:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2463 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 324913F9F8 for ; Sun, 6 Nov 2022 16:46:19 +0100 (CET) Received: by mail-ed1-f69.google.com with SMTP id e15-20020a056402190f00b00461b0576620sf6629496edz.2 for ; Sun, 06 Nov 2022 07:46:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1667749579; cv=pass; d=google.com; s=arc-20160816; b=sGPrzl7TdI8ghBfq7RFAmM3UGm4J1S313k+MKIF02FtehoJ5pr604+YLJW6sy/VTpl USvnOq3oPoknZfUshd01pNtqk7OEZPjl6vdGzbSh4wIwyWYr6/qY6bZw8WkSEt5rmr3U KXCP4o5E5Gtn7l26STpp35e5ACMTs+i5nF/M9fLT6iCKbyWkLxg6oNJvVToigO2+4LzI XEISDZWXdOUh2sCCSzD9A4MperjdZMuklxCK6nghEtM4EjMfKGSfRlsjJhxm0XxgMHUL 521sfaE2DllPVUuNimIZUGaL+leG5tod106w1iyaL2hh3X/fx9CEi4TPfmdPvVL4P9NB 8pxA== 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=E3ZCo+8yqZXjqXX8/Kqlnuzjx+LtA2vw0BMoV1WcXi0=; b=Uw6nsnyinImcoATSMfP5UWiHp0d2PFEzsjskmjuWq6bKLwoHwMjU4gnd9nLd1S68ch nWttWO8ztFv7WNH7x8Fld+pt3FzWRaZaqKp9MLtxOJXUuqBERxUtL/pTx7dGm4xgkJbH S195Ce5mTw1sH5VYi0Np2djK8cmkDg9Qf7SmA/sAonHOChCCWcTfBARvAOMqLAoP9uHp TER49m72VIA9ZltHrzZxfLMtIOT3GJzLHGJoTDV5XW/iS2532UyEw656tRF1Iz4GRuos EvYQoIqXRX2/94oTm2DFYQEux418l9KtVaP+7s5gOKR6UhG/x4+B1MbkBPW1MRU1nVBX xldg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ho8Jqqap; 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=E3ZCo+8yqZXjqXX8/Kqlnuzjx+LtA2vw0BMoV1WcXi0=; b=d77xRyu5QmQWAwWgl53afuYErCnG4SBFeQ8hqWuMSNRJ+Dji8ssUh/PT5ai4KbCOfT IqU9P5961flc755VbOCt6oJyHqWAqauTlxbl2GXM0p0rMNpOgqzOEbnljfNSRGFQHE9C Cq895hKf6GY8m6iohfMuej9tPLI7XNrt99Jb4= 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=E3ZCo+8yqZXjqXX8/Kqlnuzjx+LtA2vw0BMoV1WcXi0=; b=xVzmwd4gYCvtR3FeD3fN3EZmxvkjmh5yLcEbNmSzAvY5IzQxPM0d+465hWgZWhkMu2 8RSXM7TXMg62G5m6t9cAcE/TlocgZnOmvbJK4C+MDbami/lZSJmhq6XB4/HfS/XoIIWT jp2PCleLdSzxn4680wdcK0W3uM38Jou46fT5MqyxamnbQhHHYoNm31QHF4g6ACoxIn94 IYljnflSNvlD4aOHP6RbuPzXgRHHw4kPz42xuB9FwnRFK3CYtlKygdE1iuG4Zdz/eW7G 0nU4xIaccmFawzeAaPROTq3Ugs3N0JvKRLaN99VQssOEyYxpImiRwGzZofZu+TKhDSVX lCsg== X-Gm-Message-State: ACrzQf2znGKX0mUuDmTDQN1we5Pucg/MsHr6hP3JmYM+InkCT7FoywNQ HXRhN9gCowkYcm0/gc7OxsOCn1o5 X-Google-Smtp-Source: AMsMyM7fObcKfylVAyURD8V584Z0tuJB7ob9tZztcJNwZwXWB4Gswpa2CfHlm8SwxUc5Hj3JuxeTpQ== X-Received: by 2002:a17:907:aa1:b0:7ad:cd92:a48f with SMTP id bz1-20020a1709070aa100b007adcd92a48fmr36204240ejc.369.1667749578779; Sun, 06 Nov 2022 07:46:18 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:1856:b0:797:e443:f845 with SMTP id w22-20020a170906185600b00797e443f845ls5447082eje.5.-pod-prod-gmail; Sun, 06 Nov 2022 07:46:17 -0800 (PST) X-Received: by 2002:a17:907:10db:b0:7ae:566e:3a1f with SMTP id rv27-20020a17090710db00b007ae566e3a1fmr5730612ejb.751.1667749577610; Sun, 06 Nov 2022 07:46:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667749577; cv=none; d=google.com; s=arc-20160816; b=dlNgsw8XurQ+TF3HQcXNyWtGXnY5DN04YE236zAEx7zG0q3KA2YFoHCR1StCy/STlW fAZ3Uj3ZAy2HOuLdp4pBTX5ZqVuhSWJMcr8f92yF3bSb4AJHSWsDM+77DhookJ2bCtsO as2ijF1z+iKpyLInM6KFRBHoRBiYa4BMTrM0/NiC1KAncKFrKgkDQJT7/TQYBuAreQIh xMy4IY05+iDf0qAdSSVKp0c+db5ZzqM4SRoklKMtirqkcfo+BykzIGd5ZLRDnynjrbEw 5vD72IYOJxLGgNz4GzoWeV4iDbhdQeAkf8tKZE0hBIvpMDqLTHqFK//gHtAQlItZ0EyV I/vw== 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=Ke2ic1RycAYFmZzx9qb25pQPIAwiVR4I1nr3ghBSQyY=; b=YIAFvdRaJkzM2QL5K8uiypg2dkRP1dKi6c3xPbzc4goct/9J77gUeHM0931HNYACFn BWew+V+e/6dAR63QY4E4ftX8j2NZT7bLEyNxKwa2tAjhPeOeiuDSFJCQNdybjCTr3oAi 5w9+PkPsq5rp7s2wjL1SHlraX9jCMyBWjL+WxXTXNuBQbX+vSvq43tGW+Y6TeCCWtQfh rnyHsvZpSjVheIu5rw55obromjUwyRcdlDxKCj5YS67wqnIZiHsWRjPk+uHWpGr1+xYz 3YhnUNtNYcV/U7b0bsis70mv0Oew37XAx2kh0S43qZDpnd5YdVW1182d5xkc8aYMCUVo wNKw== 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 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 s20-20020a50ab14000000b00461f5cdb5acsor1726265edc.53.2022.11.06.07.46.17 for (Google Transport Security); Sun, 06 Nov 2022 07:46:17 -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: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 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=ho8Jqqap; 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 --- 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);