From patchwork Tue Sep 20 12:39:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arvind Yadav X-Patchwork-Id: 9341601 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 5E557607D0 for ; Tue, 20 Sep 2016 12:40:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E46829660 for ; Tue, 20 Sep 2016 12:40:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4009829675; Tue, 20 Sep 2016 12:40: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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 D053429660 for ; Tue, 20 Sep 2016 12:40:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752901AbcITMkX (ORCPT ); Tue, 20 Sep 2016 08:40:23 -0400 Received: from mail-pa0-f65.google.com ([209.85.220.65]:34290 "EHLO mail-pa0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752854AbcITMkU (ORCPT ); Tue, 20 Sep 2016 08:40:20 -0400 Received: by mail-pa0-f65.google.com with SMTP id vz6so895804pab.1; Tue, 20 Sep 2016 05:40:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=mQ0MeBf0PiBKxuWt5oGUazcHfuSZnYXUDKq2gNMtaPU=; b=VEmppYH8ivxdBRWZAG5YrEY00CNmAfKe+XazwWVdPXClTrqjv86KqOUTZlIVMULU36 2cFLB61JxsdzUpNnXiALMpSC8B3UK4nI5JROlmlJKiG3MEBv0OiCIIXt4zAyEd1rymSe cjQa+eDe6/iKwAPGRn5Abzmma7NuyZF703I/pS3Un5swII5a4/jgWzp1Py/zXTwehfDI F8qm2roJD+hTEX3+ADTovyV5MBJ3bC5sUPQNgt8q3VmY3QLGkxWYVS5xTXHkcqU3ZqwS LwzEhWc1BLez+LuZXZAgw8teBwZ3Ir+7tMNuucTzUz4quuDJ+Hl3CLBaEoZLcBP1642L aKNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=mQ0MeBf0PiBKxuWt5oGUazcHfuSZnYXUDKq2gNMtaPU=; b=nLiJ31t7IjenAHU395yBrXq8MOJHDIBb+gnSXHaMva8HNDyvt6ois8b6ImvcCXr8G4 XORPZwEMWtq7WMsxdD4ytEZ6g7ch0KK4a9TAk+gi5UORICkdQLRZsrvblPW/fQZdHGZI TSGsF0pfdBJkSED1oTSw8ei+Etyhk0KPAX1PeJtLwZE22+usTgayyAZ1eU+41BPk4Zkm MvNxYOxcchP8Mn5BtE2Z0/q0uKvVtUgd5Ygda4WgZ6VJkfLACwJUJcGiTqAnZPSENUbN 7J2SHmAI+3To+vrGb6oiEUHfxW4KoPhSk/CnuyAkVtdzsaarI4vRG76T6yz6I7FCUSxf Ngjw== X-Gm-Message-State: AE9vXwNl+gSsKrFqQv61/pwSFuMqVTLsWInsPcck0rgUvVCO+u7KGq6Z0gk63fiHB/xmcw== X-Received: by 10.66.119.136 with SMTP id ku8mr41063781pab.6.1474375219873; Tue, 20 Sep 2016 05:40:19 -0700 (PDT) Received: from symbol-HP-Z420-Workstation.symbol.com ([140.101.159.242]) by smtp.googlemail.com with ESMTPSA id h74sm53431397pfa.91.2016.09.20.05.40.16 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Sep 2016 05:40:19 -0700 (PDT) From: Arvind Yadav X-Google-Original-From: Arvind Yadav To: mturquette@baylibre.com, sboyd@codeaurora.org Cc: geert+renesas@glider.be, laurent.pinchart@ideasonboard.com, horms+renesas@verge.net.au, ulf.hansson@linaro.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Arvind Yadav Subject: [PATCH] clk: renesas: clk-mstp: Free memory and Unmap region obtained by kzalloc and of_iomap Date: Tue, 20 Sep 2016 18:09:19 +0530 Message-Id: <1474375159-16568-1-git-send-email-arvind.yadav.cs@gmail.com> X-Mailer: git-send-email 1.7.9.5 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 From: Arvind Yadav Free memory and memory mapping , if cpg_mstp_clocks_init is not successful. Signed-off-by: Arvind Yadav --- drivers/clk/renesas/clk-mstp.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/clk/renesas/clk-mstp.c b/drivers/clk/renesas/clk-mstp.c index 5093a25..19e73c8 100644 --- a/drivers/clk/renesas/clk-mstp.c +++ b/drivers/clk/renesas/clk-mstp.c @@ -179,14 +179,20 @@ static void __init cpg_mstp_clocks_init(struct device_node *np) group->data.clks = clks; group->smstpcr = of_iomap(np, 0); - group->mstpsr = of_iomap(np, 1); - if (group->smstpcr == NULL) { pr_err("%s: failed to remap SMSTPCR\n", __func__); kfree(group); kfree(clks); return; } + group->mstpsr = of_iomap(np, 1); + if (group->mstpsr == NULL) { + pr_err("%s: failed to remap MSTPCR\n", __func__); + iounmap(group->smstpcr); + kfree(group); + kfree(clks); + return; + } for (i = 0; i < MSTP_MAX_CLOCKS; ++i) clks[i] = ERR_PTR(-ENOENT); @@ -236,6 +242,10 @@ static void __init cpg_mstp_clocks_init(struct device_node *np) } else { pr_err("%s: failed to register %s %s clock (%ld)\n", __func__, np->name, name, PTR_ERR(clks[clkidx])); + iounmap(group->smstpcr); + iounmap(group->mstpsr); + kfree(group); + kfree(clks); } }