From patchwork Tue Dec 3 22:31:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 180769 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp2173745ile; Tue, 3 Dec 2019 15:07:38 -0800 (PST) X-Google-Smtp-Source: APXvYqywAz6JAyy3LXtf+jkRirCABkrNPThUfsPOcjxLMYRnuITK73x9hPWif1JRrgJm/63RpZIj X-Received: by 2002:a9d:7b4e:: with SMTP id f14mr260082oto.355.1575414458065; Tue, 03 Dec 2019 15:07:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575414458; cv=none; d=google.com; s=arc-20160816; b=SpBHaYFENXxw3fT6NaSpuc55GUa/g1I7h6cNWnI41LhaV+FYoetNFG11k61zKhje2e E1dORzEMI7s5pLNVjBUn0O7f4fih1lw9PqQrdkYWpEC14taK4YhB2W0TZsOAdkaCN+d0 GLv/bJnub63/b7/YDs8uXRNYHvHSuH7m4nxBIskaPVmOMr2YkYsELLa3RTqXGIZHMV+r o0GeRboz9KqUcDe5T+1wtYabkonr2xtrcsCiqwsnefJ6hquk9sm1ezcIWbKfmEFx6Lku 60eKaCcUYGTUrueAwfhzfaoHeJJ2FpRLeC15JhIgs7bnMKo8lDmrSKcYsM+tb5uUP4IB YHfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=clfAz/CJYWHRz0FXg90Uh28DQ52lS0WR7TsSaSTce70=; b=Q2tJds08RpJlxTjGq5FYiXvGkOuVTNgXzbQjO3QbFGn1e6tQlCYk8AkjUXJoAlOCP6 nBUr8vlB/1Q4BZ2wm2LGNo6N+/JxP7YgFzHw6tMng8RLfu/EsoeZsZ4LfRYcciR2E1Ih SyAZv5ozx+58vsXRuDrcvPOR8U80uvZKHO9EwnZfsCTezCYZsqSw7XUjjHCxyCW2HMt4 +LzCSrFohXtCJwKppLyTNZUzs5UyPsiQpqvk2Rfes2/UhJJV6gnSEg7Qm2S7zkg9j5DL bxAFqjF6hgSjZmL3/jV7eQU+DvicJAD4Mcllq3h/2xIitgXDSzCF4qltdI+dXweNGtpT vxgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=druYHK3d; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y22si1645149oti.269.2019.12.03.15.07.37; Tue, 03 Dec 2019 15:07:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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=@kernel.org header.s=default header.b=druYHK3d; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727842AbfLCXHg (ORCPT + 15 others); Tue, 3 Dec 2019 18:07:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:36924 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727981AbfLCWq4 (ORCPT ); Tue, 3 Dec 2019 17:46:56 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 82BF020684; Tue, 3 Dec 2019 22:46:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575413216; bh=L4XOYS3b/3flJVtxje65XySINl6P8L3mSzV9zxODNIc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=druYHK3dwtZCEeZNwVZgAbHu9OPr8ifiCSyeq1Q6ppV2oAzQjHGdLZx+X5BNWqdl6 E/umfMO2CsFaiSanMS8XHwnoVz+97VVPrnxSpQoA0ctoHa9nlLZI4kN+4AHYm+9TAy K+kPhiTLskx2sGHiQcLwL3SWpKeQW9tBpMAAMLbM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marek Szyprowski , Krzysztof Kozlowski , Chanwoo Choi , kbuild test robot , Sylwester Nawrocki , Sasha Levin Subject: [PATCH 4.19 006/321] clk: samsung: exynos5433: Fix error paths Date: Tue, 3 Dec 2019 23:31:12 +0100 Message-Id: <20191203223427.452305159@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191203223427.103571230@linuxfoundation.org> References: <20191203223427.103571230@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Marek Szyprowski [ Upstream commit faac3604d05e8015567124e5ee79edc3f1568a89 ] Add checking the value returned by samsung_clk_alloc_reg_dump() and devm_kcalloc(). While fixing this, also release all gathered clocks. Fixes: 523d3de41f02 ("clk: samsung: exynos5433: Add support for runtime PM") Signed-off-by: Marek Szyprowski Reviewed-by: Krzysztof Kozlowski Acked-by: Chanwoo Choi [s.nawrocki: squashed patch from K. Kozlowski adding missing slab.h header] Reported-by: kbuild test robot Signed-off-by: Krzysztof Kozlowski Signed-off-by: Sylwester Nawrocki Signed-off-by: Sasha Levin --- drivers/clk/samsung/clk-exynos5433.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/drivers/clk/samsung/clk-exynos5433.c b/drivers/clk/samsung/clk-exynos5433.c index 426980514e679..302596dc79a2c 100644 --- a/drivers/clk/samsung/clk-exynos5433.c +++ b/drivers/clk/samsung/clk-exynos5433.c @@ -16,6 +16,7 @@ #include #include #include +#include #include @@ -5527,6 +5528,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; @@ -5535,12 +5538,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; } }