Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9171041pxu; Mon, 28 Dec 2020 08:20:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJyQ8Dd/Y5Ajm7K8QG040mdunncT/Mgwwv27l9fCT7kdJgYFmePzPsTAsZGnH2e0sjnKPsDP X-Received: by 2002:a17:906:ca08:: with SMTP id jt8mr40878471ejb.368.1609172413672; Mon, 28 Dec 2020 08:20:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609172413; cv=none; d=google.com; s=arc-20160816; b=NxNODVg07P9Bv1VWa85lYKy4jw4dwcRZAvSXJT3njHp8kfZVuDKQuZFcHg6GpvbZTO F4E7B9tc52QYHb+mOi6obQ2ZJAyMMPy8WK1b1vQmRSMG4NCHYFAf5uz8V7ZH4Yb8UgkG NssT9jnrYyWxBSzj6tdlumL6DCUUTsFCT0AmdhvzBRqhu686ueiccRaUPFQiCrcOfxBV GZuRNMP5+idMG8X6SN7GtgGPgpDSORpcfjPqgCn8u9pKkYIwYjZyUFRZgAsuEC3noA5m JXcj587nQLXN4Qt8T+6M6/D5iJBkU2Iwvco2V0C5JQUiKKbhq8SWmd0mlOYNktEGIcRd ilMw== 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=AX5v58+HwQiWjl1itnKnrZzlsScOfSvRDTcdPF7a5MA=; b=ZI+WXyrcDnD3LK26tjSea8SZV7vXEwb5RW2A5zkhC9osUOmhE0aSf2nhTQM1UtOQrx NZLUDNhl9NTcDA8+AZdurhlNRTm26qw0pRPUJRMj5CL3ke9BZIlfSaF74ooAL6386VOj g5/snPLxw855wV64CiptI1O4HSc9NSCAP8hgrOqEfYVKZkVKvV3G8on7gez9JWHqsb97 CmE5ipwmf3oicj7TCZ9iaNSysisrIrRhwUs4YL6e9+GQ1lVQGfznofK7QMWNSN65HlU/ PdV2xlU5GA12fxq05fy/iOVECLFYkKKad4vFIRx4Hc3Bz9hmLgcZPIQidUh6uI+ZBP+g ll1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GgEw6SgO; 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 k18si20523833eds.42.2020.12.28.08.19.49; Mon, 28 Dec 2020 08:20:13 -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=GgEw6SgO; 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 S1733276AbgL1QSX (ORCPT + 99 others); Mon, 28 Dec 2020 11:18:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:43694 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732707AbgL1NPn (ORCPT ); Mon, 28 Dec 2020 08:15:43 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 600F122C7B; Mon, 28 Dec 2020 13:15:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609161327; bh=Pfhr6gtaEmtm4tpojp8fahW8fu5iIc3nUB0qyfR5wYs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GgEw6SgO7+akuVoLp6+KX2DvkxyhwDSBEVGypktx1LFpL7qPTE9/f9M2NfgO9KjlW tg0ynhHT/GTTjMl2smXg4Faz/+kNlpnK3MnAnU78i8GRtg+xFQlqNuBOCsMhLaCZ25 l6xiLZ4F6bKH1KTo3+6jTB9PP9uHN5m2pJZp3Q5M= 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.14 170/242] clk: ti: Fix memleak in ti_fapll_synth_setup Date: Mon, 28 Dec 2020 13:49:35 +0100 Message-Id: <20201228124913.069387364@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124904.654293249@linuxfoundation.org> References: <20201228124904.654293249@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 071af44b1ba85..e33ce851837e4 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