Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp343720pxu; Thu, 7 Jan 2021 06:33:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxZomV7v3p/sa24tQLIdapvX9KIhhQOPFsc0LArw54XVnfXI9aU1Fl03WnoptyM5pjhmbUg X-Received: by 2002:a17:906:3b8b:: with SMTP id u11mr6381396ejf.489.1610030027445; Thu, 07 Jan 2021 06:33:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610030027; cv=none; d=google.com; s=arc-20160816; b=V25xgcn52a7A/mr4SpVZDiB4sEvX9FaV6je9p066GSUB8udMfWFAHKBtRcozV32wu/ wPK9/HMm0h/8Bh3O/YztBGZqq1EGnumLwBkyF7lrB62xTjfk8P/qs7kvItRTwX/vXnks f3wyEr+3mFW/ZUpdvh8WTpHJW0Ne8Uqd7ph2F0185CFEYe+h6ncFov2WQMY+bLnlXgRm yn2cdW40A0P/7ZlHSJxKe4sXEiiXsk+gda4LWOOGMskpcx9cexJV0/VbQ6BA+a3CiYS+ m6ZR/PQw5al4PdkGmA32uChbToPtQlLCQ2K+zAQLVinJWpcGhdVmY5Dz7wr3J1IDeK6h tZRg== 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=jSZo28CDrRaLwLZLuL3v2v0UaZAxF838wgC1TLu+4Dk=; b=vamVFjv4DLgyKqHBuyIMMonH1MvHh8VpqejpXb4pb6ds486Ff3OcQk2PS1rUFOcxUh x/qA0sJdSPIpyAXWl2rJEX2ZVCx5pzbBFuBe6KQeseVL3uKmDhPtmDNCP93k3dMr3gpX S+MXTZWXrIMqShy9tOxaxzzeKvWTifDLx90Ez0JR7TGUqyrsXBj3VnZPMLdI2uAfxR1d 3BdYqdqFrLh3FnLV3T3sz9Xt0loFNiHytxo4WSxKoPSyhEuD+ROlfYgxXFrGaxWiQan7 TBFhj0hXTdD9muEoPhizZCkKGyrJr5OIv+FejXzmQstE03Ng0li+gZiroz7ktBpdeMGd sRiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2OrhXSfU; 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 u9si2300969edd.596.2021.01.07.06.33.24; Thu, 07 Jan 2021 06:33:47 -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=2OrhXSfU; 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 S1729118AbhAGOb4 (ORCPT + 99 others); Thu, 7 Jan 2021 09:31:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:45974 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729099AbhAGObz (ORCPT ); Thu, 7 Jan 2021 09:31:55 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 79ED523383; Thu, 7 Jan 2021 14:30:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610029853; bh=pzRhHs59aiMH3Yt9MNi2DX7MUHYsbgwMmFKqAuHKQ34=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2OrhXSfUWPKfUhuYTK/fUFcKcOeuDrhS2j/avK8Y1ec9KNoIit/4BscTx8Hxx/bSD E806V/STD7f333vfHJaeqDBg/+hjnkYq8UlG7sxDms9EVIXejvUJAerB+m66DyyO/0 uufR5Ie5t60kVloKBY4TmzBkKFsD2rN22NBoWI1w= 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 4.14 19/29] rtc: sun6i: Fix memleak in sun6i_rtc_clk_init Date: Thu, 7 Jan 2021 15:31:34 +0100 Message-Id: <20210107143055.669299315@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210107143052.973437064@linuxfoundation.org> References: <20210107143052.973437064@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 8eb2b6dd36fea..1d0d9c8d0085d 100644 --- a/drivers/rtc/rtc-sun6i.c +++ b/drivers/rtc/rtc-sun6i.c @@ -230,7 +230,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); @@ -246,7 +246,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, @@ -257,7 +257,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; @@ -266,6 +266,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