From patchwork Wed Oct 2 08:53:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 174957 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp472536ill; Wed, 2 Oct 2019 01:53:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqzAtAw5GeeYnCDBE3uBSstrIVqgotG9yxK8s3eO3bKw16wFo8gMDq3ZktHAD1mpkUZXMpDc X-Received: by 2002:a17:906:1f89:: with SMTP id t9mr1943066ejr.241.1570006405014; Wed, 02 Oct 2019 01:53:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570006405; cv=none; d=google.com; s=arc-20160816; b=GcIE6OzLVeQX5I64rVufCuN0JZCC15MT9ZIGFEzAEQeMUuIeLG7o8AvkA8WzxpeTBH kcbe6YK8YRVD1bvo0cGCHHYJU+MQUu7Fvln4goluL9YDbCzwGv54P2Qyj2FLU2xi6LLZ HlBc7JUN7erGmwY8cKXPAPP5Tsk6+Oi+c1PZYI3N2Bulyk/QeL5mTEOGxjEZID4QjM7t TmRnt6uRmE+W4Ndmf7RK8SBVt7Qm8R+mNzraNbQXNo+4owPx3FMOQq/3c5jz41bjmg6R Xx/ZLYE+iuH2gxAS2MRaYdKx7D/frn7tXxCGQSXswPBygQbSeTj7g5J7RvtVLiNDKcIu 50rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=MnXaUYuEAohAtC2FHsIuzLDXlz81hjmPhN4i/nld/kc=; b=Dr9JIhZsJLlxoy4vqAkgtNNq1vaoyR48igYFI7bjvfnKhrkxwks9nysEP6SD8FgsTF HZAkGZGCfC8B2XXMaKFCNw+hkeAV4BD4lluAb+f+Xmyv2ZBMFK1oUNWRVzlAwrngx5Fm 9vRSavIzMaBvAdz142juWVW3+FwUr/W9xKxZ6dLEm7zAcoFL38yDqyWbDmrigfE5dmCK ZP8ZwpJimQMW+26gUJSxKuTTLnv2MIDegVV+padlm6VELdCTlZsYfdwirr/vZ8JlrbiH KpCtfBkRuqq08QH8A7062/EWpv/ofCHqHwX5tmX77w3+XSH+jBaBaXW53eOxqs5sqmps jasA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=BVs5qQa4; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id oe23si10455060ejb.199.2019.10.02.01.53.24; Wed, 02 Oct 2019 01:53:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=BVs5qQa4; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726410AbfJBIxY (ORCPT + 3 others); Wed, 2 Oct 2019 04:53:24 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:53753 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726162AbfJBIxX (ORCPT ); Wed, 2 Oct 2019 04:53:23 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20191002085321euoutp0174a1ae4ec414c1ab8e577cb1f1ede1fd~JyIENidAO1504015040euoutp019 for ; Wed, 2 Oct 2019 08:53:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20191002085321euoutp0174a1ae4ec414c1ab8e577cb1f1ede1fd~JyIENidAO1504015040euoutp019 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1570006401; bh=MnXaUYuEAohAtC2FHsIuzLDXlz81hjmPhN4i/nld/kc=; h=From:To:Cc:Subject:Date:References:From; b=BVs5qQa4NvplCV3bsy+zlzoJjQMzjgXppXQqGXt4XiWRYMttv8TYqhbUHZwSFe6Bm uAo4ohHI5kuLYIn9yGU4h3tGilPvfHD6aZdvN28hBKG1N0PMDhWgEvSVaN/UTRuaxx x3I0EjsfY1A84Gm1vFL8qTpEj4NZLv4Tk3y/CGcs= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20191002085321eucas1p1add21893275cb5c088f68cea28a53b46~JyID8DAaq3021030210eucas1p1k; Wed, 2 Oct 2019 08:53:21 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 5B.AB.04374.185649D5; Wed, 2 Oct 2019 09:53:21 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20191002085320eucas1p2e4c35fe7783deb38fbd2e9f87f4f1234~JyIDhpCrq3164031640eucas1p2M; Wed, 2 Oct 2019 08:53:20 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20191002085320eusmtrp1b29df999c4aff39ebc3d455bdaad1fbe~JyIDg--2q2399823998eusmtrp1T; Wed, 2 Oct 2019 08:53:20 +0000 (GMT) X-AuditID: cbfec7f5-4ddff70000001116-50-5d9465815cfe Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 5D.53.04117.085649D5; Wed, 2 Oct 2019 09:53:20 +0100 (BST) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20191002085320eusmtip2dc968cf2ef2f25c29e6d19e5412542c5~JyIDHytO72990529905eusmtip21; Wed, 2 Oct 2019 08:53:20 +0000 (GMT) From: Marek Szyprowski To: linux-clk@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , Sylwester Nawrocki , Chanwoo Choi , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz Subject: [PATCH] clk: samsung: exynos5433: Fix error paths Date: Wed, 2 Oct 2019 10:53:09 +0200 Message-Id: <20191002085309.9473-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrGIsWRmVeSWpSXmKPExsWy7djP87qNqVNiDW6sFbfYOGM9q8X1L89Z Lc6f38Bu8bHnHqvFjPP7mCzWHrnLbtH+9CWzA7vHplWdbB59W1YxenzeJBfAHMVlk5Kak1mW WqRvl8CVcftbE2PBR+6Ks91bmBoYr3F2MXJySAiYSNzZspUFxBYSWMEocfhZbhcjF5D9hVFi z5ddTBDOZ0aJ8/9Ps8B0rPs+lQUisZxRYnHvXna4ljs/b4FVsQkYSnS97WIDsUUEHCQ+f3rN CFLELPCYUWLrya/MIAlhASuJtilfwRpYBFQlPr17zApi8wrYSFx438AKsU5eYvWGA8wgzRIC R9gkDk6ZBZVwkXjz+DcbhC0s8er4FnYIW0bi9OQeFoiGZkaJh+fWskM4PYwSl5tmMEJUWUsc Pn4RaBIH0E2aEut36UOEHSW2v/jEAhKWEOCTuPFWECTMDGRO2jadGSLMK9HRJgRRrSYx6/g6 uLUHL1xihrA9JJbPWscKCdRYiT+H21knMMrNQti1gJFxFaN4amlxbnpqsXFearlecWJucWle ul5yf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2x/rhnk2HSjFKe410tklNj5aTmVMkqsRRnJBpqMRcVJwIA2prboE4CAAA= X-CMS-MailID: 20191002085320eucas1p2e4c35fe7783deb38fbd2e9f87f4f1234 X-Msg-Generator: CA X-RootMTR: 20191002085320eucas1p2e4c35fe7783deb38fbd2e9f87f4f1234 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20191002085320eucas1p2e4c35fe7783deb38fbd2e9f87f4f1234 References: Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org Add checking the value returned by samsung_clk_alloc_reg_dump() and devm_kcalloc(). While fixing this, also release all gathered clocks. Signed-off-by: Marek Szyprowski --- drivers/clk/samsung/clk-exynos5433.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) -- 2.17.1 Reviewed-by: Krzysztof Kozlowski Acked-by: Chanwoo Choi Acked-by: Sylwester Nawrocki diff --git a/drivers/clk/samsung/clk-exynos5433.c b/drivers/clk/samsung/clk-exynos5433.c index 7824c2ba3d8e..0b60316331a0 100644 --- a/drivers/clk/samsung/clk-exynos5433.c +++ b/drivers/clk/samsung/clk-exynos5433.c @@ -5584,6 +5584,8 @@ static int __init exynos5433_cmu_probe(struct platform_device *pdev) data->clk_save = samsung_clk_alloc_reg_dump(info->clk_regs, info->nr_clk_regs); + if (!data->clk_save) + return -ENOMEM; data->nr_clk_save = info->nr_clk_regs; data->clk_suspend = info->suspend_regs; data->nr_clk_suspend = info->nr_suspend_regs; @@ -5592,12 +5594,19 @@ static int __init exynos5433_cmu_probe(struct platform_device *pdev) if (data->nr_pclks > 0) { data->pclks = devm_kcalloc(dev, sizeof(struct clk *), data->nr_pclks, GFP_KERNEL); - + if (!data->pclks) { + kfree(data->clk_save); + return -ENOMEM; + } for (i = 0; i < data->nr_pclks; i++) { struct clk *clk = of_clk_get(dev->of_node, i); - if (IS_ERR(clk)) + if (IS_ERR(clk)) { + kfree(data->clk_save); + while (--i >= 0) + clk_put(data->pclks[i]); return PTR_ERR(clk); + } data->pclks[i] = clk; } }