From patchwork Tue Nov 13 11:57:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 10680387 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 9BDCB13BF for ; Tue, 13 Nov 2018 11:57:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 87E8029FE1 for ; Tue, 13 Nov 2018 11:57:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B0B029FF2; Tue, 13 Nov 2018 11:57:54 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW 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 815A029FE1 for ; Tue, 13 Nov 2018 11:57:53 +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=Mpa6r43Vfs9JRn 72YHlpESw3uQc9g1wjJHygFf5f+u98YW9Dh4OgkeUsuVFUvdbyodghnczH4wo5UqurHbSCnxlLFTc HGjXkTYcMCR1xupN6IMs/qzve/DcqW4uYPgi1F6otInPSavJql5e2idLh4zRIcM+VYfc44aM+5g2o YUP542gtyFvb7Knv6rvhKaBUktuFOD34G5H6e328wwZQwQU3wew81XSSyxaOYaJPMXLrkH4KbJgyU 53LbnQ2+W7xOiIUdU0yabNoH61tAgyzQNt5DIoEChu30vZ7dYKurD/U5YrkC8yW4Uz6DAU0f9IIR0 c89AF/+Q2Kbbggq2pTCA==; 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 1gMXKJ-0003Wq-Dy; Tue, 13 Nov 2018 11:57:51 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMXKH-0003WG-RK for linux-arm-kernel@bombadil.infradead.org; Tue, 13 Nov 2018 11:57:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: 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=fJ06/MEsQS8wIywHorlvQqUqrYoodnmIZrcXjxSdJq0=; b=q+G6pzn2O5NHHSqkVrHLjlIx4 2nuI+OIZ/PhkN9snYgL885ly+trdoahd/7DpKYsx6VW1ZCYmSlbhTHoiYKNfh53V0Ea5m/8lfGQI/ nszlfmRhHE0CGUJrLuSMEhLfANzM9j4lecYlDan3piw+x9zkKAZ5LYjseZ596RK4ManDaWG1zn+iP l14DN5G6Bhmc6Yn3wPDtD3ozGcCo57rchjWimux6S8QuAQUxHiSodtuVmIdRIuN7zZY22PIATYK7b WCBwGrR4aguSDqWULT2t30SKlXVJejp3yk/hlT4EwwEbG92bexFFTRs+16IepdTb6/aRs80T9yHYB MhWfApxJQ==; Received: from mail-lj1-f195.google.com ([209.85.208.195]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMXKD-00046g-8e for linux-arm-kernel@lists.infradead.org; Tue, 13 Nov 2018 11:57:47 +0000 Received: by mail-lj1-f195.google.com with SMTP id l15-v6so2352092lja.9 for ; Tue, 13 Nov 2018 03:57:35 -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=PksblGNuDlk8316JxlpUEZNngzXzhqXgNG/EAefk2On4MgEe/XvrgS0ATHqwubrg+P nqs9HX7G4nhBwN+kCzvsGve/PWsMAQiNi9+DjhE7Hhl8maqigyyv2kDsgXe5yNqLY25z B/GWxWEoMV/aJk627zEI5gjP9K7bD/lI0DrNLfdBXGpETTvtrJc+6fFbbD6N+mUJxN4K JpS0i/Tzp8T9zGa64ZjAKj0eSReMAuFYyrNsU7kRPpFOHoVea+2I/TNc1XovVrP/3zVW 7KUhSJU1+6ctoKAKbqvWUO9KmpGFBigu22bwUMvcJHY9DL3ROQYLOIGZFZ6cfDfWu7aG Dpow== X-Gm-Message-State: AGRZ1gLfcfp5xUWyEByEs+eC2NfStp6Ww8yW6Bp1lmHaMSF+xif7X3HH /T+mk3HKAJ0mO+ePQFsLhpM= X-Google-Smtp-Source: AJdET5dPbccSJIhU4ykGo/7sZ/6SWA6kO+vJeerN5LGWL5sFshLw+a7sE+sfVQzxYkAhfiqGWuVZ6Q== X-Received: by 2002:a2e:8099:: with SMTP id i25-v6mr3224659ljg.174.1542110253613; Tue, 13 Nov 2018 03:57:33 -0800 (PST) Received: from localhost.localdomain ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id f18-v6sm3745263ljf.36.2018.11.13.03.57.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Nov 2018 03:57:33 -0800 (PST) Date: Tue, 13 Nov 2018 13:57:17 +0200 From: Matti Vaittinen To: mazziesaccount@gmail.com Subject: [PATCH v4 2/8] 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-20181113_065745_364349_7E06F9F6 X-CRM114-Status: GOOD ( 18.46 ) 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: linux-doc@vger.kernel.org, Michael Turquette , Daniel Kurtz , Sebastian Reichel , David Brown , Lee Jones , linux-clk@vger.kernel.org, Rob Herring , Jonathan Corbet , Andrey Smirnov , "Rafael J. Wysocki" , Russell King , Krzysztof Kozlowski , Chanwoo Choi , Andy Gross , Huang Shijie , Guenter Roeck , Bartlomiej Zolnierkiewicz , linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Stephen Boyd , Matti Vaittinen , linux-kernel@vger.kernel.org, Akshu Agrawal 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, };