Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9210990pxu; Mon, 28 Dec 2020 09:22:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJx6XR9/7d2ICBf9lEIfUpNqvYKkjEHEsCsIo1VzubwdptccuXcAfKbqaof8ML2LuyTWKywe X-Received: by 2002:a05:6402:1ad1:: with SMTP id ba17mr42094776edb.51.1609176154500; Mon, 28 Dec 2020 09:22:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609176154; cv=none; d=google.com; s=arc-20160816; b=pP4594MIoZzndXw9LEGrAvNOBUunb/em00PjWT2Ct4j0vAZqYxjDUlB+/8OjZo9Z/w +JmisTk6vjjobjtMU2Ksdv/dOwT3kAbmmRM/GjCKtKMRrdHkVZaZxjiYasY7CzV9d4gB OwTliit0UXlNGpN36Jh0K68oZr08RispWPz1qqfbKjPG/pK4EXOV125toIevOoRtSbZX W5lbyH93an687mOLzcLC8NCzNFx12SkGKHIjU+1Je4k1Bgyo1tsq/oX1pVZH6Puyldeu U/9IKn2/I5Bx9xfX2wmjM6Woa2Hcu05jeGf4xmig0a/BMDMVH1ITMAhcrNVzCIfS8o3/ 9Wag== 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=iqCY9dIyMWVDQTuCvKi7mT5wDUJpvkOYAt0NX2S5WnY=; b=uVydGc5a3undFTNGxWY2F8alWEtY4LFCGaCSbVpH8sdZgxrydack2vxRxICTY1kW9q pUBwbuol+GE0e0qbTtuU6C/Dj95o+yfocUql2/OpjP34q1cgfOC7LHlzTDJJiFn/gVaL BNY+8bbfTUGAz5pekHtEHJWFj2k5PNAb2STDCK6SAYTNhwUQFfHcXQ1YKh/qvLJ2VRiM 01ppnaM1my0t5p3N+9M5/1rALlqxkn6/Y+XyXoSeOgZZyi896y2B/EiVL8ELxdAGwX57 DJ4TjO+552rZrFo5SQyy+a534/KFgeu4CydNXt6LQzIZoRjp9LNP2gGzBKrlU2CrlGbl AHsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=E0yDvi9b; 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 q14si14312877ejx.155.2020.12.28.09.22.12; Mon, 28 Dec 2020 09:22:34 -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=E0yDvi9b; 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 S1728349AbgL1M5p (ORCPT + 99 others); Mon, 28 Dec 2020 07:57:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:53728 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729002AbgL1M5j (ORCPT ); Mon, 28 Dec 2020 07:57:39 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id A552B229C6; Mon, 28 Dec 2020 12:57:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160244; bh=qCPZnGg71nA+DH7EWZ4M3f0d3yuNrU/7XVXfB7ri/M0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E0yDvi9b908dT0Njykr8PmSL2POmZHvk00kJ7yHqKLM4dDcK9VI7Xj5iPJOUiOlSw 4hIyfT+Osgk/wUU/y42fhZmlmg+V8K+wuVi0FuoAhH3MyK77RAiA4xqMI0vLqJbnAI L8d1VViBljKkSJvNMMWCXsmy7XEHzrUae7MpNWF8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Zhang Qilong , Tony Lindgren , Stephen Boyd , Sasha Levin Subject: [PATCH 4.4 090/132] clk: ti: Fix memleak in ti_fapll_synth_setup Date: Mon, 28 Dec 2020 13:49:34 +0100 Message-Id: <20201228124850.777225725@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124846.409999325@linuxfoundation.org> References: <20201228124846.409999325@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: Zhang Qilong [ Upstream commit 8c6239f6e95f583bb763d0228e02d4dd0fb3d492 ] If clk_register fails, we should goto free branch before function returns to prevent memleak. Fixes: 163152cbbe321 ("clk: ti: Add support for FAPLL on dm816x") Reported-by: Hulk Robot Signed-off-by: Zhang Qilong Link: https://lore.kernel.org/r/20201113131623.2098222-1-zhangqilong3@huawei.com Acked-by: Tony Lindgren Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/clk/ti/fapll.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/clk/ti/fapll.c b/drivers/clk/ti/fapll.c index 66a0d0ed8b550..02ff499e36536 100644 --- a/drivers/clk/ti/fapll.c +++ b/drivers/clk/ti/fapll.c @@ -497,6 +497,7 @@ static struct clk * __init ti_fapll_synth_setup(struct fapll_data *fd, { struct clk_init_data *init; struct fapll_synth *synth; + struct clk *clk = ERR_PTR(-ENOMEM); init = kzalloc(sizeof(*init), GFP_KERNEL); if (!init) @@ -519,13 +520,19 @@ static struct clk * __init ti_fapll_synth_setup(struct fapll_data *fd, synth->hw.init = init; synth->clk_pll = pll_clk; - return clk_register(NULL, &synth->hw); + clk = clk_register(NULL, &synth->hw); + if (IS_ERR(clk)) { + pr_err("failed to register clock\n"); + goto free; + } + + return clk; free: kfree(synth); kfree(init); - return ERR_PTR(-ENOMEM); + return clk; } static void __init ti_fapll_setup(struct device_node *node) -- 2.27.0