Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp13956168pxu; Mon, 4 Jan 2021 08:57:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJyklJPgfb74ncrlxxf06xgkHhw/U83tNB4SJsipHfB2EQedUbaxxVnIchVBvolWICpy2QGc X-Received: by 2002:a17:906:74d9:: with SMTP id z25mr66874141ejl.217.1609779420653; Mon, 04 Jan 2021 08:57:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609779420; cv=none; d=google.com; s=arc-20160816; b=NksvgIf6wCFFc9xlrnE/BGiqwjlFA8mEWPGBm5f5aU9ZkuDz05uQ/lkwKq9G2ZHrPo MD0qwU90KkHcAZXtriijW5BBJa9q+nQyLin5tNH3ryxULUe2kQNAPoMaPjDHU7vrIvpq 4IrnZu9Z8B5r89DF/B60MI8yqnHh3yZL/F2RpQya4Gh9FG3MkzQjpMbb+FTCxE68Tjtu dNKQBAlhmJpOJKDsXDByu51lUHgmU2VRjvIZ37v0G8OXEIQxSR2EFMu4URSKlONVlClq fzneLA5g5OXpAu0EkTRNE/Y68xVDj4F1viCNCxyji9K4ve2GBU55j2sHCl56/RKYh7iE KESw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fLYmSxWkzu/FlXtf2jmE8mMAn2rpc6UcLwFYgVkdVuY=; b=g+iCLGsLMkkeqqOAGxGo4R6lgWTq7D4rpqANNf+p+YTnyFcDwutBCc//AHP0JasnsG rUKgxOI6z59RyCLDZbolWdwgmeNfdvSRQdU1E+UriCdnOp0djXShDAc18qYyRe/Latvq PcrIBHgBChAMoYMla9S6l6Zk8YeC+4WsNw6jMzAqxHWrN9Pl24GTDINz3znGxis5IYJ2 uiXteg7orlA0He2GWqAhf5AoOBml4WOgoyZRCxXphItysDZw7P1UOLjOYvuhRQ3aDNSh A4i/R52WO0moh4+CY2xebru1m2TJxWsRMD9qcYn0vtreXWIw/J8k/pVIQ4wBl2w30XHn w3KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Wp7YU+WH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g24si28861210ejh.77.2021.01.04.08.56.37; Mon, 04 Jan 2021 08:57:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Wp7YU+WH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728564AbhADQEs (ORCPT + 99 others); Mon, 4 Jan 2021 11:04:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:40796 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727819AbhADQDh (ORCPT ); Mon, 4 Jan 2021 11:03:37 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id B0CFE2245C; Mon, 4 Jan 2021 16:03:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609776202; bh=qxrP4zc/ImSoS5qSPaJn5wozIced+jjFdbENYDbKl/w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wp7YU+WHhq/KUS/6PE1MRw2esxxELWY/rvTD7y2VkkOEEsoyxf3pC4O5BdG+lQBMA 2GdKO/lByyTGlMaMEqzdPBsqcm0R9spp2jeh2KxdcxIr+kDvb8/02ETiUme1DMovtd 3AwFUo3O68rfUU/duJCkYtiL6i7V4TdWfSDyZf94= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dinghao Liu , Alexandre Belloni , Sasha Levin Subject: [PATCH 5.10 39/63] rtc: sun6i: Fix memleak in sun6i_rtc_clk_init Date: Mon, 4 Jan 2021 16:57:32 +0100 Message-Id: <20210104155710.717942230@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210104155708.800470590@linuxfoundation.org> References: <20210104155708.800470590@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dinghao Liu [ Upstream commit 28d211919e422f58c1e6c900e5810eee4f1ce4c8 ] When clk_hw_register_fixed_rate_with_accuracy() fails, clk_data should be freed. It's the same for the subsequent two error paths, but we should also unregister the already registered clocks in them. Signed-off-by: Dinghao Liu Signed-off-by: Alexandre Belloni Link: https://lore.kernel.org/r/20201020061226.6572-1-dinghao.liu@zju.edu.cn Signed-off-by: Sasha Levin --- drivers/rtc/rtc-sun6i.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c index e2b8b150bcb44..f2818cdd11d82 100644 --- a/drivers/rtc/rtc-sun6i.c +++ b/drivers/rtc/rtc-sun6i.c @@ -272,7 +272,7 @@ static void __init sun6i_rtc_clk_init(struct device_node *node, 300000000); if (IS_ERR(rtc->int_osc)) { pr_crit("Couldn't register the internal oscillator\n"); - return; + goto err; } parents[0] = clk_hw_get_name(rtc->int_osc); @@ -290,7 +290,7 @@ static void __init sun6i_rtc_clk_init(struct device_node *node, rtc->losc = clk_register(NULL, &rtc->hw); if (IS_ERR(rtc->losc)) { pr_crit("Couldn't register the LOSC clock\n"); - return; + goto err_register; } of_property_read_string_index(node, "clock-output-names", 1, @@ -301,7 +301,7 @@ static void __init sun6i_rtc_clk_init(struct device_node *node, &rtc->lock); if (IS_ERR(rtc->ext_losc)) { pr_crit("Couldn't register the LOSC external gate\n"); - return; + goto err_register; } clk_data->num = 2; @@ -314,6 +314,8 @@ static void __init sun6i_rtc_clk_init(struct device_node *node, of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); return; +err_register: + clk_hw_unregister_fixed_rate(rtc->int_osc); err: kfree(clk_data); } -- 2.27.0