From patchwork Tue Nov 8 08:23:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajendra Nayak X-Patchwork-Id: 9416861 X-Patchwork-Delegate: sboyd@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3BFFD60459 for ; Tue, 8 Nov 2016 08:24:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E9FE28481 for ; Tue, 8 Nov 2016 08:24:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 22619289C1; Tue, 8 Nov 2016 08:24:24 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6DCB28481 for ; Tue, 8 Nov 2016 08:24:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752948AbcKHIYX (ORCPT ); Tue, 8 Nov 2016 03:24:23 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:37770 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752861AbcKHIYW (ORCPT ); Tue, 8 Nov 2016 03:24:22 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 833DF61566; Tue, 8 Nov 2016 08:24:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1478593461; bh=2CiTP9bsA5nYFc3DGEYkKHZDPvTIkBVZpAm1YQyM4Qw=; h=From:To:Cc:Subject:Date:From; b=FkVucH6gSG0QgFoigdxHDa1/FShw8eflHf/tZ1Gml1wgmVfk2SC+EMsyfdfG0snGY tw8ceLXYXC2U2uHtbmr02fBonsj/N1XZnu7ZwCHP7TbL6HVEWdjW4f6SboGmzXagTA TuQXhX3jSDyWgX7fUJ/sbsf6tr/TrOpxKAwwaaZ0= Received: from blr-ubuntu-34.ap.qualcomm.com (unknown [202.46.23.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: rnayak@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 1539761568; Tue, 8 Nov 2016 08:24:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1478593461; bh=2CiTP9bsA5nYFc3DGEYkKHZDPvTIkBVZpAm1YQyM4Qw=; h=From:To:Cc:Subject:Date:From; b=FkVucH6gSG0QgFoigdxHDa1/FShw8eflHf/tZ1Gml1wgmVfk2SC+EMsyfdfG0snGY tw8ceLXYXC2U2uHtbmr02fBonsj/N1XZnu7ZwCHP7TbL6HVEWdjW4f6SboGmzXagTA TuQXhX3jSDyWgX7fUJ/sbsf6tr/TrOpxKAwwaaZ0= DMARC-Filter: OpenDMARC Filter v1.3.1 smtp.codeaurora.org 1539761568 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=pass smtp.mailfrom=rnayak@codeaurora.org From: Rajendra Nayak To: sboyd@codeaurora.org, mturquette@baylibre.com Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Rajendra Nayak Subject: [PATCH] clk: Free struct clk allocated during clk_hw_register() Date: Tue, 8 Nov 2016 13:53:50 +0530 Message-Id: <1478593430-23102-1-git-send-email-rnayak@codeaurora.org> X-Mailer: git-send-email 1.8.2.1 Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP With clk_hw_register() API we hide the struct clk from the caller and return an int error code instead, so the caller (clk provider) is not expected to use hw->clk on return. Free the memory, and mark hw->clk as NULL before returning. Signed-off-by: Rajendra Nayak --- drivers/clk/clk.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 0fb39fe..f81e4aa 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2628,7 +2628,15 @@ struct clk *clk_register(struct device *dev, struct clk_hw *hw) */ int clk_hw_register(struct device *dev, struct clk_hw *hw) { - return PTR_ERR_OR_ZERO(clk_register(dev, hw)); + struct clk *c; + + c = clk_register(dev, hw); + if (IS_ERR(c)) + return PTR_ERR(c); + + __clk_free_clk(c); + hw->clk = NULL; + return 0; } EXPORT_SYMBOL_GPL(clk_hw_register);