From patchwork Mon Dec 3 12:19:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 10709421 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 BB44414BD for ; Mon, 3 Dec 2018 12:20:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8F992B4DF for ; Mon, 3 Dec 2018 12:20:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D0902B4E3; Mon, 3 Dec 2018 12:20:30 +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 9D6022B4E2 for ; Mon, 3 Dec 2018 12:20:27 +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:Cc: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:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sIi/llkjppitL2PnFr19iFLJfrAZLczbs981OSu9R+s=; b=YqJof057CPZiO0 nf+X74k3fwB5p0WqdgSVKdGAMLkISOL1nd+ED/hsu7ZGkRIvYzgEg4Z6XqgbH6KH3RvFefCBkB52h KjR+Jvz8H4ghzyrdZ1osUnyWh0Kpomn3CB2bT3kw+g0cdgseKkepknEkz8gCZnnh8GIUgjL7bgsNZ NK+BI8tihGWQpvYkYv5NxpKAAhO5VoQMG58DY1VOFbotE8dLMiekAbWU3G775z/zSCu/KRc2ug3gC 9j8iIf6A7JoYIo+ruo9qVCLf1PH0RwGoJ7GE6jVuo2uBbte0ug2h6s8rQ9w2jD7eSxahj5UK3Hx5w 3qU+8hSyVxvmxjlXJN0g==; 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 1gTnCu-0000ja-CR; Mon, 03 Dec 2018 12:20:12 +0000 Received: from mail-lf1-f66.google.com ([209.85.167.66]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gTnCj-00081L-0o for linux-arm-kernel@lists.infradead.org; Mon, 03 Dec 2018 12:20:10 +0000 Received: by mail-lf1-f66.google.com with SMTP id f23so8928226lfc.13 for ; Mon, 03 Dec 2018 04:19: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:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=fJ06/MEsQS8wIywHorlvQqUqrYoodnmIZrcXjxSdJq0=; b=QYDVnyT7cdqs89C1+UUypR4H0kaBAV59FOKqFIy0+0RAuoRPqIpMJiTDN2tsTSIRx6 RpW0qoRnO4NLJ3rS6RmBAxQftAAlDHNzLvviz4DG7MpFFWwi7jh8ZZvSvWc2FxTVn2PP s/D8rojKGvG7aRim2lmV17KMRO/vuFLCtc7UjEjpAHZeMboS4MhjiHWjo1rqvac/4jMl IB6rGt9OzCSvTBoEH4VRGC0w8RnfUXaKNAJqFwOhbIytVotSfh/SnJHtGJY8V81F2m98 cwCuhZ560XqEpDPTigszMi/JkjzZMF/CyaWbE1S0PjokqF4aaBq/n8hgK3qfXYHAyDJN F3tw== X-Gm-Message-State: AA+aEWaT0orBBTPFLVOV7gC+ID6z/ekto/xWmAL9reMYpEEuqod4174z k2YeeTAZeQCEqYXuXo6cAGg= X-Google-Smtp-Source: AFSGD/WgnRyEklbhrzoAdgtWZ2HOe0X9TsjA1Nq4WBaT2wWTmfqv/XbKXL3exfZ8C1DvNTpyHjbTzQ== X-Received: by 2002:a19:f510:: with SMTP id j16mr8516533lfb.35.1543839588876; Mon, 03 Dec 2018 04:19:48 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id b21sm2309452lfi.7.2018.12.03.04.19.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Dec 2018 04:19:48 -0800 (PST) Date: Mon, 3 Dec 2018 14:19:35 +0200 From: Matti Vaittinen To: mazziesaccount@gmail.com, matti.vaittinen@fi.rohmeurope.com Subject: [PATCH v5 3/9] clk: clk-max77686: Clean clkdev lookup leak and use devm 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-20181203_042001_074287_D34F5E27 X-CRM114-Status: GOOD ( 16.48 ) 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: , Cc: david.brown@linaro.org, linux-clk@vger.kernel.org, b.zolnierkie@samsung.com, sboyd@kernel.org, linux-kernel@vger.kernel.org, mturquette@baylibre.com, rafael.j.wysocki@intel.com, linux-doc@vger.kernel.org, linux@armlinux.org.uk, krzk@kernel.org, akshu.agrawal@amd.com, cw00.choi@samsung.com, djkurtz@chromium.org, pavel@ucw.cz, pombredanne@nexb.com, andy.gross@linaro.org, andrew.smirnov@gmail.com, lee.jones@linaro.org, sjhuang@iluvatar.ai, linux-arm-kernel@lists.infradead.org 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_parent_hw_provider. Signed-off-by: Matti Vaittinen Reviewed-by: Krzysztof Kozlowski --- drivers/clk/clk-max77686.c | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/drivers/clk/clk-max77686.c b/drivers/clk/clk-max77686.c index 22c937644c93..e65925d5e412 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,9 @@ 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_parent_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 +263,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 +283,6 @@ static struct platform_driver max77686_clk_driver = { .name = "max77686-clk", }, .probe = max77686_clk_probe, - .remove = max77686_clk_remove, .id_table = max77686_clk_id, };