Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9039816pxu; Mon, 28 Dec 2020 05:09:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJxq2Tb2uPJ8X/+AZgruHFm67+r0VqECQ+9zfhN0jR/FCyV0zwFCW8rWjtzuF4XsjK+jn/ix X-Received: by 2002:a05:6402:8d9:: with SMTP id d25mr41802243edz.278.1609160976796; Mon, 28 Dec 2020 05:09:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609160976; cv=none; d=google.com; s=arc-20160816; b=NRzjBRpcasMjCGrdVxfW7K9jQPjiKwkJXlPg28AAKYeD39ocReYg0g53seAEWqgKCD vRIMkI78vwWO8zDcY2Ct0yUCgbYI9hZJpAqth2B/+g3UZ+WFueMmbKjE5Equ7r3PPei/ Jlnj1q+Q+g42xjwWJImWz0pHNFQ67nkjs5Bimcqcv2tNgzeYSwL9qQ7NlSnrPV1QZPjG wXtb3KIz+0pDlxsLz87QAeB+VIq3udT7GPX/MLQWih5WX6Rrjz+or66Zs/d+mD87DVi2 My17nA0De5OjmDcAfzTIN1w/ld4WESxpG8sDoDOeYEE6t+fqeqNuJ2Wv5ZqdLuLYXDtL stng== 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=HpiuLPoJR2Xz3JK39/G1fomdHrhqsl/ZB3YObyib/XGtojZbfXl5ULwRAbd2CN2IV6 CRAFH+2nIAfows5Bm5RvcQS/EVmstzN+xGVdraQ+A5kEdM380Bkiry+OdqcmCtqM2O2s rgE+1CIGFO4Fcev12glsflwndBUqbVWkSVsGrBZizxec+bTZRJ5dlUmIKajjrBIrQPi8 CIyN6Plp4dxG8zGUqlhIK9rLgKPP/ioEb3QzTWWRL/72s0MWwqD0ClGS7GZPHq8iddgo GzT2rn2aKsEuPv5nob9oL8WENTCaIY2BBhInFplfF6RvS2ZLEoS6Saix3Ef2EdcwHPZx d9fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sS4Ne+vx; 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 s20si20465370edr.121.2020.12.28.05.09.14; Mon, 28 Dec 2020 05:09:36 -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=sS4Ne+vx; 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 S1728911AbgL1NH1 (ORCPT + 99 others); Mon, 28 Dec 2020 08:07:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:34126 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730976AbgL1NGU (ORCPT ); Mon, 28 Dec 2020 08:06:20 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2FEB221D94; Mon, 28 Dec 2020 13:05:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160739; bh=qCPZnGg71nA+DH7EWZ4M3f0d3yuNrU/7XVXfB7ri/M0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sS4Ne+vxgRBk0BQvQg8j+X+ka4MrU3Gpd+Kl2lGroKkBe/2lFCKYZTwH9kIPLTlWA f4aZOe95/8yNoOUssYDZ02lwxOAMQ8KpAJLFos61w5gEf/JgcMsO6KlEEHv3zVPH1I qlAkuOPd0KrHfr/DzfxxeyQrdPJKL8uSk+CgFAO4= 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.9 124/175] clk: ti: Fix memleak in ti_fapll_synth_setup Date: Mon, 28 Dec 2020 13:49:37 +0100 Message-Id: <20201228124859.257486233@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124853.216621466@linuxfoundation.org> References: <20201228124853.216621466@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