From patchwork Fri Dec 7 11:09:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 10717971 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7D518109C for ; Fri, 7 Dec 2018 11:11:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 660EA2E229 for ; Fri, 7 Dec 2018 11:11:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 596DE2E31C; Fri, 7 Dec 2018 11:11:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E16A82E229 for ; Fri, 7 Dec 2018 11:11:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Z0ARYMw+oLBLc9oVtIgRAuLbpkjn1V528aeVQA3kCfc=; b=N9M5Uv9SwGqx3F hZ93eeUKfaBiisOHsEbkc9E4VStt3hr7Mbc/8QlYhmkokPPwgPztpAZHlqQh/XITg08XOzlVpYsQM Wf7ZQP6KsQWuYpYD5ZQk131YpUkYaL+Zp16VjOlNbOBqnRECr2fR2xMtsCYALB5KrZClfO3OJN/1C 15php0lBf6WZ5sNY3+tabiLcdgSLRisD0ojA0Ar1seTP06fTHBsD1aVc/QPH7HKFcA0YSkDVz6ujQ 6kwSdL/ra+x0WlkxabAQlh5Jbw8xbK//J1I8nXRhmeZxp8AjE0Kf29nhVHHrCHNFootn/28Mw9PJP Y9ayjNNLNaaCcz6KELJA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gVE2A-0007MC-QW; Fri, 07 Dec 2018 11:11:02 +0000 Received: from mail-lf1-f67.google.com ([209.85.167.67]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gVE1B-0005Vo-IZ for linux-arm-kernel@lists.infradead.org; Fri, 07 Dec 2018 11:10:12 +0000 Received: by mail-lf1-f67.google.com with SMTP id a16so2742116lfg.3 for ; Fri, 07 Dec 2018 03:09:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=XpsSi0+yUp3jaVjKpWoYffPxMgxENs/oMkn95BNj54M=; b=Sv5S4Z4VSRYumQoJU2RRtxQPirrDj7DrPUyf87bKsOfoGTQfgN9d1L0b9o8qsUijRP ekYsPR85V+zrld11GST68K+Fu9FvP8S/pPH4gWxV74UdMR3medfocV8QxUOhH1mWkl8H vuNyJVkZJVgfCtL9lBkMUfqvs3YSO+Q9uSOB7CRzt++nMLbT3iRUF+Mnnzu//nka3lij LF7RZGW9+GJwKdWq1MRBdYMtxAJGi5kSJNA0dw+PW6aGQdII+r9p5T1HJg38fH6BHfVk tlygk7VUbq9Tg5CZL3FwCgOL/c9nj9L5obNT2o4AVqbmlTQ/VONT5adoMqUc4kdHIQ4h uUxw== X-Gm-Message-State: AA+aEWZEy4isLxysLkbUkJWaowlUp7GEuLnBSI8pTiPqc8o4HS00g1gL WuDn6aksO+KE6v+d09/ZvoE= X-Google-Smtp-Source: AFSGD/WhQp0STFv63bRo7DIho34LywT8ZBOhkrooIuEVt9GeMiSR0LpaxIDo5OkKHUZJzheGTqn+Qw== X-Received: by 2002:a19:e601:: with SMTP id d1mr1098451lfh.71.1544180989196; Fri, 07 Dec 2018 03:09:49 -0800 (PST) Received: from localhost.localdomain (84-253-205-125.bb.dnainternet.fi. [84.253.205.125]) by smtp.gmail.com with ESMTPSA id s24sm542384lfc.30.2018.12.07.03.09.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Dec 2018 03:09:48 -0800 (PST) Date: Fri, 7 Dec 2018 13:09:39 +0200 From: Matti Vaittinen To: matti.vaittinen@fi.rohmeurope.com, mazziesaccount@gmail.com, corbet@lwn.net, cw00.choi@samsung.com, krzk@kernel.org, b.zolnierkie@samsung.com, mturquette@baylibre.com, sboyd@kernel.org, linux@armlinux.org.uk, pombredanne@nexb.com, sre@kernel.org, vkoul@kernel.org, linux@roeck-us.net, pavel@ucw.cz, sjhuang@iluvatar.ai, andrew.smirnov@gmail.com, djkurtz@chromium.org, akshu.agrawal@amd.com, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v7 1/3] clkdev: add managed clkdev lookup registration Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181207_031001_976975_4B58F0D6 X-CRM114-Status: GOOD ( 17.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Clkdev registration lacks of managed registration functions and it seems few drivers do not drop clkdev lookups at exit. Add devm_clk_hw_register_clkdev and devm_clk_release_clkdev to ease lookup releasing at exit. Signed-off-by: Matti Vaittinen --- Documentation/driver-model/devres.txt | 1 + drivers/clk/clkdev.c | 111 +++++++++++++++++++++++++++------- include/linux/clkdev.h | 4 ++ 3 files changed, 93 insertions(+), 23 deletions(-) diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt index 43681ca0837f..dbf14326243b 100644 --- a/Documentation/driver-model/devres.txt +++ b/Documentation/driver-model/devres.txt @@ -238,6 +238,7 @@ CLOCK devm_clk_put() devm_clk_hw_register() devm_of_clk_add_hw_provider() + devm_clk_hw_register_clkdev() DMA dmaenginem_async_device_register() diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index 9ab3db8b3988..4621f8a91fc0 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c @@ -401,6 +401,23 @@ static struct clk_lookup *__clk_register_clkdev(struct clk_hw *hw, return cl; } +static int do_clk_register_clkdev(struct clk_hw *hw, + struct clk_lookup **cl, const char *con_id, const char *dev_id) +{ + if (IS_ERR(hw)) + return PTR_ERR(hw); + /* + * Since dev_id can be NULL, and NULL is handled specially, we must + * pass it as either a NULL format string, or with "%s". + */ + if (dev_id) + *cl = __clk_register_clkdev(hw, con_id, "%s", dev_id); + else + *cl = __clk_register_clkdev(hw, con_id, NULL); + + return *cl ? 0 : -ENOMEM; +} + /** * clk_register_clkdev - register one clock lookup for a struct clk * @clk: struct clk to associate with all clk_lookups @@ -423,17 +440,8 @@ int clk_register_clkdev(struct clk *clk, const char *con_id, if (IS_ERR(clk)) return PTR_ERR(clk); - /* - * Since dev_id can be NULL, and NULL is handled specially, we must - * pass it as either a NULL format string, or with "%s". - */ - if (dev_id) - cl = __clk_register_clkdev(__clk_get_hw(clk), con_id, "%s", - dev_id); - else - cl = __clk_register_clkdev(__clk_get_hw(clk), con_id, NULL); - - return cl ? 0 : -ENOMEM; + return do_clk_register_clkdev(__clk_get_hw(clk), &cl, con_id, + dev_id); } EXPORT_SYMBOL(clk_register_clkdev); @@ -456,18 +464,75 @@ int clk_hw_register_clkdev(struct clk_hw *hw, const char *con_id, { struct clk_lookup *cl; - if (IS_ERR(hw)) - return PTR_ERR(hw); + return do_clk_register_clkdev(hw, &cl, con_id, dev_id); +} +EXPORT_SYMBOL(clk_hw_register_clkdev); - /* - * Since dev_id can be NULL, and NULL is handled specially, we must - * pass it as either a NULL format string, or with "%s". - */ - if (dev_id) - cl = __clk_register_clkdev(hw, con_id, "%s", dev_id); - else - cl = __clk_register_clkdev(hw, con_id, NULL); +static void devm_clkdev_release(struct device *dev, void *res) +{ + clkdev_drop(*(struct clk_lookup **)res); +} - return cl ? 0 : -ENOMEM; +static int devm_clk_match_clkdev(struct device *dev, void *res, void *data) +{ + struct clk_lookup **l = res; + + return *l == data; } -EXPORT_SYMBOL(clk_hw_register_clkdev); + +/** + * devm_clk_release_clkdev - Resource managed clkdev lookup release + * @dev: device this lookup is bound + * @con_id: connection ID string on device + * @dev_id: format string describing device name + * + * Drop the clkdev lookup created with devm_clk_hw_register_clkdev. + * Normally this function will not need to be called and the resource + * management code will ensure that the resource is freed. + */ +void devm_clk_release_clkdev(struct device *dev, const char *con_id, + const char *dev_id) +{ + struct clk_lookup *cl; + int rval; + + cl = clk_find(dev_id, con_id); + WARN_ON(!cl); + rval = devres_release(dev, devm_clkdev_release, + devm_clk_match_clkdev, cl); + WARN_ON(rval); +} +EXPORT_SYMBOL(devm_clk_release_clkdev); + +/** + * devm_clk_hw_register_clkdev - managed clk lookup registration for clk_hw + * @dev: device this lookup is bound + * @hw: struct clk_hw to associate with all clk_lookups + * @con_id: connection ID string on device + * @dev_id: format string describing device name + * + * con_id or dev_id may be NULL as a wildcard, just as in the rest of + * clkdev. + * + * To make things easier for mass registration, we detect error clk_hws + * from a previous clk_hw_register_*() call, and return the error code for + * those. This is to permit this function to be called immediately + * after clk_hw_register_*(). + */ +int devm_clk_hw_register_clkdev(struct device *dev, struct clk_hw *hw, + const char *con_id, const char *dev_id) +{ + int rval = -ENOMEM; + struct clk_lookup **cl; + + cl = devres_alloc(devm_clkdev_release, sizeof(*cl), GFP_KERNEL); + if (cl) { + rval = do_clk_register_clkdev(hw, cl, con_id, dev_id); + if (!rval) + devres_add(dev, cl); + else + devres_free(cl); + } + return rval; +} +EXPORT_SYMBOL(devm_clk_hw_register_clkdev); diff --git a/include/linux/clkdev.h b/include/linux/clkdev.h index 4890ff033220..ccb32af5848b 100644 --- a/include/linux/clkdev.h +++ b/include/linux/clkdev.h @@ -52,4 +52,8 @@ int clk_add_alias(const char *, const char *, const char *, struct device *); int clk_register_clkdev(struct clk *, const char *, const char *); int clk_hw_register_clkdev(struct clk_hw *, const char *, const char *); +int devm_clk_hw_register_clkdev(struct device *dev, struct clk_hw *hw, + const char *con_id, const char *dev_id); +void devm_clk_release_clkdev(struct device *dev, const char *con_id, + const char *dev_id); #endif From patchwork Fri Dec 7 11:10:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 10717993 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 591F21731 for ; Fri, 7 Dec 2018 11:26:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42ABF2DEE6 for ; Fri, 7 Dec 2018 11:26:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 353B52DF08; Fri, 7 Dec 2018 11:26:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 39D892DEE6 for ; Fri, 7 Dec 2018 11:26:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Gr3oYPL5eHitldSKeq6SxrBKUe/EE/vqb34jqpx4Cgk=; b=uIhe0huz53DDZl Z8KyAzL+CSKdgNkFxQwT0VBvXArQl3ZYdEGab4DFoi9/NI4VNaCBaqdzDk5rHmWyjNwwIiUdvlstG ymwx/ZM1QOAGvtKikV+1XKC4hH2t42jHjYuzsWP50+0vQ/7JuiVfC9+0sBKumSzJr4bN1mgUYocaY cVWI4es3vSu/6JgKVWXXZG1gNnChPmCBQtbAkHJ/UU6J3qV7bMiCD5gDW8e/FN9Ni2vfyN2bGfGX2 wz3WTVUKpXAHe5Nl7UxzEi7TF+mThOoI8LAmKxCfUAQBpDuBD6cbVeotEcl1NIwm/UaWdmGSiiqMs Rqev5QUZUzCpI4/tz1LA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gVEGd-0004jk-96; Fri, 07 Dec 2018 11:25:59 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gVEGb-0004dA-Sq for linux-arm-kernel@bombadil.infradead.org; Fri, 07 Dec 2018 11:25:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:To:From:Date:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=C+QFX5ZVtWnMLn09mrcjeXEfm3+SxpJLl35PxOTC/Sw=; b=SbsVst67aQ7bk7DNnEGEGFMQX xwWq5ubj7qMqB+gsEU4V/MXkejmWwiSIt0M6nInKujlUp2CacBKV1p+dv9FZ96p1Uepljq8UYHTIz pC9pKPaKPh+4cHrAX7H2fx1DFE2oMPlLwsDnUuJisItcybTmZn69aaQ23O+AA1E7ldSOz42oL3LCZ mclf9PfIOWQ9NwXsG2cjhviKWziLS3F/GpiH8270YY5iEt0hcbf5758QTWhsraAQu6/VH9zlFqucG NoYnD060R6ZWtEYsk/UHRplBJTFj48DvH/nwqhzvzQafn5Fkl+5wOsE6ULCNSZrgZ6J33a5kUFdV6 V4wq3RWOg==; Received: from mail-lf1-f67.google.com ([209.85.167.67]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gVE1k-0005SJ-7j for linux-arm-kernel@lists.infradead.org; Fri, 07 Dec 2018 11:10:37 +0000 Received: by mail-lf1-f67.google.com with SMTP id p86so2731210lfg.5 for ; Fri, 07 Dec 2018 03:10:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=C+QFX5ZVtWnMLn09mrcjeXEfm3+SxpJLl35PxOTC/Sw=; b=IF6mUPYVPP7P9Tj5Em9RUCYP9hI4F2aCXwea9ikUooFCPnURqNOX3B2Ba+KBcSYlKi YGuVeyfHPc/D2ZISm5GneIIAY38kKjSiUpay/7MDOhiWf0GKyiOyS0Yx2np1nV/QT4PA IZq68lgf96oguejtMPAQrRqaHUts9KIovAyPaB4/SPGv2/SXGKQ64lWFyh1pvxaAQDiC XyU1HEJzX86zT0DjbT8XA5M+qlQVXBYWiVXdXqj3LcHYMPjZfZjOL30ZKLizb5lgbxpR DlZS7pSSa/l1+moR8EUxp0815LNNVEocOdSW60rQCijbAZQqexEZHIGjSxscQt2i1wLK iV5Q== X-Gm-Message-State: AA+aEWZRh45C5agNRwsh2Uu9g0Kyw9+jbrDw1e2ECf2P/2Xa9c7bsElf 54rsZCXpv6/rTpDAXH46V+8= X-Google-Smtp-Source: AFSGD/Whm5MmfMrEEnOtTwnd4+77ZXPMpVbXHuumw8iiSi8SYe4BVa/dBSDett9NRYCGJAb1M6Hi0Q== X-Received: by 2002:a19:9e11:: with SMTP id h17mr1119787lfe.73.1544181024117; Fri, 07 Dec 2018 03:10:24 -0800 (PST) Received: from localhost.localdomain (84-253-205-125.bb.dnainternet.fi. [84.253.205.125]) by smtp.gmail.com with ESMTPSA id z9sm533992lfj.79.2018.12.07.03.10.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Dec 2018 03:10:23 -0800 (PST) Date: Fri, 7 Dec 2018 13:10:15 +0200 From: Matti Vaittinen To: matti.vaittinen@fi.rohmeurope.com, mazziesaccount@gmail.com, corbet@lwn.net, cw00.choi@samsung.com, krzk@kernel.org, b.zolnierkie@samsung.com, mturquette@baylibre.com, sboyd@kernel.org, linux@armlinux.org.uk, pombredanne@nexb.com, sre@kernel.org, vkoul@kernel.org, linux@roeck-us.net, pavel@ucw.cz, sjhuang@iluvatar.ai, andrew.smirnov@gmail.com, djkurtz@chromium.org, akshu.agrawal@amd.com, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v7 2/3] clk: clk-max77686: Clean clkdev lookup leak and use devm Message-ID: <05409aafa108c77b2b878ed9663717c4b4a183ca.1544177090.git.matti.vaittinen@fi.rohmeurope.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181207_111036_266711_43DBDECE X-CRM114-Status: GOOD ( 16.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP clk-max77686 never clean clkdev lookup at remove. This can cause oops if clk-max77686 is removed and inserted again. Fix leak by using new devm clkdev lookup registration. Simplify also error path by using new devm_of_clk_add_hw_provider. Signed-off-by: Matti Vaittinen Reviewed-by: Krzysztof Kozlowski --- Please note that the patch #2 requires this change to work correctly: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git/commit/?h=clk-next&id=05502bf9eb7a7297f5fa6f1d17b169b3d5b53570 drivers/clk/clk-max77686.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/drivers/clk/clk-max77686.c b/drivers/clk/clk-max77686.c index 22c937644c93..3727d5472450 100644 --- a/drivers/clk/clk-max77686.c +++ b/drivers/clk/clk-max77686.c @@ -235,8 +235,9 @@ static int max77686_clk_probe(struct platform_device *pdev) return ret; } - ret = clk_hw_register_clkdev(&max_clk_data->hw, - max_clk_data->clk_idata.name, NULL); + ret = devm_clk_hw_register_clkdev(dev, &max_clk_data->hw, + max_clk_data->clk_idata.name, + NULL); if (ret < 0) { dev_err(dev, "Failed to clkdev register: %d\n", ret); return ret; @@ -244,8 +245,8 @@ static int max77686_clk_probe(struct platform_device *pdev) } if (parent->of_node) { - ret = of_clk_add_hw_provider(parent->of_node, of_clk_max77686_get, - drv_data); + ret = devm_of_clk_add_hw_provider(dev, of_clk_max77686_get, + drv_data); if (ret < 0) { dev_err(dev, "Failed to register OF clock provider: %d\n", @@ -261,27 +262,11 @@ static int max77686_clk_probe(struct platform_device *pdev) 1 << MAX77802_CLOCK_LOW_JITTER_SHIFT); if (ret < 0) { dev_err(dev, "Failed to config low-jitter: %d\n", ret); - goto remove_of_clk_provider; + return ret; } } return 0; - -remove_of_clk_provider: - if (parent->of_node) - of_clk_del_provider(parent->of_node); - - return ret; -} - -static int max77686_clk_remove(struct platform_device *pdev) -{ - struct device *parent = pdev->dev.parent; - - if (parent->of_node) - of_clk_del_provider(parent->of_node); - - return 0; } static const struct platform_device_id max77686_clk_id[] = { @@ -297,7 +282,6 @@ static struct platform_driver max77686_clk_driver = { .name = "max77686-clk", }, .probe = max77686_clk_probe, - .remove = max77686_clk_remove, .id_table = max77686_clk_id, }; From patchwork Fri Dec 7 11:10:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 10717973 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A4864109C for ; Fri, 7 Dec 2018 11:11:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E0722E248 for ; Fri, 7 Dec 2018 11:11:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 80A162E356; Fri, 7 Dec 2018 11:11:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3AECE2E248 for ; Fri, 7 Dec 2018 11:11:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Bj85HQydJjcE2NdNkr71FsMX1jdknW/AWvhC2H1lUUA=; b=RVzH9QTYnBijcs nIVVovW1wLuFR2jY1425y0hzy2LV0BZiD5dFOpE/kFDHPLXpnlljv55Mfrq8jUldB2Az7bpY2y6RC hJ4UmQK8fKQAC+iTq70WAU9TLU/D+s7g5bxYNTu2SCbSOGEfc7cF094euawG2qXLABwI7ez4zLO+m 5RswtWP3VwAx0eWmVnL5Dz+CpdwB3UVLwc4PnMr6pAhRXXwY+SuKBLw4SP4JM7gMbpHECpGH7qZ0q QLbrqcfcHDRAzc4fmVlG6PxABO3GXyyTjzDbdGUDdKwAmL9zuO56Lr11wqtyWI49NiIJX4JbcF29p 6my5QFOT7vYRrKOWFD9w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gVE2M-0007QG-63; Fri, 07 Dec 2018 11:11:14 +0000 Received: from mail-lj1-f193.google.com ([209.85.208.193]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gVE2J-0007M9-Eq for linux-arm-kernel@lists.infradead.org; Fri, 07 Dec 2018 11:11:12 +0000 Received: by mail-lj1-f193.google.com with SMTP id n18-v6so3203448lji.7 for ; Fri, 07 Dec 2018 03:11:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=IPaANYg+BKvew3Ns6tmkF9qat1yGp0JhQQkX999AOmA=; b=DhKREUIgeCAl8rCb4187t9PeS6a5fLRe5AfolRZQ/JBpLNaQVCXlK2ZTBWIrh1oKeS g4OVy0Xnjx1rY/DKVYcrNvamPvi7rFnWwSND48eiiuxboLNKofNewqxOG+R8bBMafPiP gyEoyplPs+YrOwWW+ZTwF/Yyy75d8VUVVV+Y1I/kLwsYEk0Xuf67SZiPE0jq7Rv4wOCx naQbsrNqSUSg1c/FDelnFQI44cnly/VmnSAL8iAbt+p1x/4qyBz9a3y6lVPj44LbxA2A r2rfoEqmK4tJxWtEdrVI/gpUnvP4DN4rSG0IGZsVC4yDIyZzXObjVy5YBed68BMuHXzZ lVsg== X-Gm-Message-State: AA+aEWavP4avmL2R16K9byllxSS7VhwOI/ypIrpuz1sZ4zJNY9hzevod IDWnUCl9C3rl1Rjk+OfdYqA= X-Google-Smtp-Source: AFSGD/XfomwTlfwAe22p+SJG0lO7BIYoQtcGAA7ynED9gQVIJ8DPFu04mYExY5/4RW93QAjgp7daSg== X-Received: by 2002:a2e:197:: with SMTP id f23-v6mr1095815lji.144.1544181059423; Fri, 07 Dec 2018 03:10:59 -0800 (PST) Received: from localhost.localdomain (84-253-205-125.bb.dnainternet.fi. [84.253.205.125]) by smtp.gmail.com with ESMTPSA id q127-v6sm571001ljq.45.2018.12.07.03.10.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Dec 2018 03:10:58 -0800 (PST) Date: Fri, 7 Dec 2018 13:10:51 +0200 From: Matti Vaittinen To: matti.vaittinen@fi.rohmeurope.com, mazziesaccount@gmail.com, corbet@lwn.net, cw00.choi@samsung.com, krzk@kernel.org, b.zolnierkie@samsung.com, mturquette@baylibre.com, sboyd@kernel.org, linux@armlinux.org.uk, pombredanne@nexb.com, sre@kernel.org, vkoul@kernel.org, linux@roeck-us.net, pavel@ucw.cz, sjhuang@iluvatar.ai, andrew.smirnov@gmail.com, djkurtz@chromium.org, akshu.agrawal@amd.com, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v7 3/3] clk: clk-st: avoid clkdev lookup leak at remove Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181207_031111_498582_77CEA81E X-CRM114-Status: GOOD ( 12.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Use devm based clkdev lookup registration to avoid leaking lookup structures. Signed-off-by: Matti Vaittinen --- drivers/clk/x86/clk-st.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/clk/x86/clk-st.c b/drivers/clk/x86/clk-st.c index 3a0996f2d556..25d4b97aff9b 100644 --- a/drivers/clk/x86/clk-st.c +++ b/drivers/clk/x86/clk-st.c @@ -52,7 +52,8 @@ static int st_clk_probe(struct platform_device *pdev) 0, st_data->base + MISCCLKCNTL1, OSCCLKENB, CLK_GATE_SET_TO_DISABLE, NULL); - clk_hw_register_clkdev(hws[ST_CLK_GATE], "oscout1", NULL); + devm_clk_hw_register_clkdev(&pdev->dev, hws[ST_CLK_GATE], "oscout1", + NULL); return 0; }