From patchwork Tue Dec 4 11:35:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 10711577 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 42810109C for ; Tue, 4 Dec 2018 11:36:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C8B92A4CD for ; Tue, 4 Dec 2018 11:36:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1E2112B72C; Tue, 4 Dec 2018 11:36:33 +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 C9DA82A4CD for ; Tue, 4 Dec 2018 11:36:32 +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=zvLZ4C+IMVDDUKQ/zl/LZzgyKQq/7/4hTB6Az7djFus=; b=KibGbMrBlVsD2t jWaiRD/8ZC05u8+a/QHfAsgd02d0SVc2Z1oQ857SMhks/77x0P1uN/J8wPFzW+yTGyJRV5TLkP+xw kX8TGxL2bLeg4B6LcSCMj6u5tBpal5XSFqeU9KP8u0Qz9MB3OMMMrqxRDG/DhxAKeWpf9EwkC0bqs WeMTyIVLhafIRUI/jINPYFauB7tZMTcK3nKJXDcyYkpeI2dDc4wubTH+fzDjTsJWe+EzdvzZHq6hy qfxB6F/k+9bPNjSTOjNnplrfHKqnLavN72PNIzCQoTpt8uck5474mvls2bM/A4qXDdFYPvv/18wqN 5hlFG8Q+3Sv7Ic9uXi6w==; 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 1gU903-0001tK-3n; Tue, 04 Dec 2018 11:36:23 +0000 Received: from mail-lf1-f65.google.com ([209.85.167.65]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gU8zz-0001s6-Ce for linux-arm-kernel@lists.infradead.org; Tue, 04 Dec 2018 11:36:21 +0000 Received: by mail-lf1-f65.google.com with SMTP id a16so11695169lfg.3 for ; Tue, 04 Dec 2018 03:36:09 -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=OMDW0BBEob281Ew2OkowKuqON5GnzN6B7Aw/Pih2LVk=; b=Nw7MWraioXrvFaJ9i0tHAzQID8aqJQC3exGyg5tNHzZXywJE85eLhN2G8E3oQWpjJR 6F3h7Ywj11dLarBY2J6tSji090UcxbifPeshA1ipZbXTp5j6w8MPM+bBcX/+Ihu8TGiC +Wni4m5M9Rz54ewmRB+4n/IzHXMyr/sYP74HNDk3BHPhxycv9F0CP32hucvkp/EnPEfD nqceFI9GQCYCV0U5jtUT5QCVXsIzWTPaazZKpwNc2lMPHNl6FQK9QMaUoJddnBVg7j7s L6mOWxBFLWzihOD8309w+7hld8RjKptSWv4oyUGh5Mwf3RhahxxAbLgN5iM0gbk+4x4l 26eg== X-Gm-Message-State: AA+aEWaibVjiBLPQEjS1ozHQhc1922/r7AnI5cHpV+aYFT53FOXgoIo2 joSolgKfwazDIv3cHmWGcMY= X-Google-Smtp-Source: AFSGD/WcGn4UOdUXoiEFJFp1gk/+VJnPX6XF/xdRrHNWCYk2XW10C7I3CIDk3QLQS2zpJI16OeMN6Q== X-Received: by 2002:a19:4e59:: with SMTP id c86mr12231019lfb.132.1543923367575; Tue, 04 Dec 2018 03:36:07 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id k11-v6sm3069000ljk.40.2018.12.04.03.36.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Dec 2018 03:36:06 -0800 (PST) Date: Tue, 4 Dec 2018 13:35:52 +0200 From: Matti Vaittinen To: mazziesaccount@gmail.com, matti.vaittinen@fi.rohmeurope.com Subject: [PATCH v6 04/10] clk: clk-max77686: Clean clkdev lookup leak and use devm Message-ID: <41eb57e80f1a8bcd5e48e1d0b86859c5aae61d2e.1543922403.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-20181204_033619_433430_2C7E842A X-CRM114-Status: GOOD ( 15.57 ) 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, 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_hw_provider. Signed-off-by: Matti Vaittinen Reviewed-by: Krzysztof Kozlowski --- 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, };