Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9404946pxu; Mon, 28 Dec 2020 15:24:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJxpo9fXbmqwjSZm6xMdLaKMDQTYMsWBX6Ki/V9tRnYAnwNYp3cc79GFs2C8wHCoq6tM7edL X-Received: by 2002:a17:907:a8a:: with SMTP id by10mr42769371ejc.423.1609197845855; Mon, 28 Dec 2020 15:24:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609197845; cv=none; d=google.com; s=arc-20160816; b=DTHeEr1MYLDrzQg5O6v9pOrFOgbHuuh2MSyScBycYrNCRdLWpVII4bj/Xg/8vSuCae Vp4Q2Z14uRQ3IQagxjpKaMglaO3dbfL/5FmRKuB59SqzCluE76voaDooxQTvemhHDeUU xQ5OzcgRFz7kci0huJHVYM+s3At8EjW0NckvJcf2V/BvAsesByk0uxHdiq89zW3dn/z6 clyVGKNF8/9eJDsNnTMzx5/CEDgMj0ZJXCFfmrBUC+KJS0V11R74/7yEAEs5gGcS0kNi UXTC93VYgGlaYFntZYoOMXcXjnAhXFRW90BvU86mYN1YuViOSRGl4aZCpQL3TTlAm1OZ Isjg== 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=fE0Lz4uFOBnJlwGOEfj6QvB8Aoj/owPdb731qeXU4/0=; b=phZTydUJOZPxrgN2HPmRqmCIQ0qVKIASHLxUiIjXR8txfsq0VGNz7MU/pPTzZ852z5 5qTEMQvmkbSCt8mzYOoToOad6A1MA4NhdYh7gv88xfwtFiHS+G5/ZTNbr31Q9SBimpEb KESm8j2PsXRNW9s5EdR6avLQETzEJq4Q1unhZoCazlAC7Cy5SNQ2uHyY/DNfejUshjuN h23onY/AdZUP3hS2MOiahDD4PQx17r648GIc2pPvZPqiHs9YsUhAcMRRL74dUdJu6BCr CQzFXfitk63coRv/Ue0bL+Nv2ckaEmBTFiVilAZ2CkaYH6gOrzS7dKLcXRcQkiNXIOH1 GRRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=S2fck6jP; 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 c23si19162124ejk.52.2020.12.28.15.23.44; Mon, 28 Dec 2020 15:24:05 -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=S2fck6jP; 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 S2502925AbgL1OXu (ORCPT + 99 others); Mon, 28 Dec 2020 09:23:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:57978 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502772AbgL1OXM (ORCPT ); Mon, 28 Dec 2020 09:23:12 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1FAD62245C; Mon, 28 Dec 2020 14:22:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165376; bh=hJPvZ98uWfYMgHk6MR39rxcwhu74WZNtnAqFZCpUbFE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S2fck6jPY0DlMKlchEANqYRM9Ry9rhtx1a8fN3KBOYBMYcq/CbwhcBbO9pR0JnKkG ififZgl+nIePGt3dDSNzFPJuHIC+ZhPr6U7oP4w3K7RFuM2j9uKJVoHwiQmVVFoVu9 6Kmfw0AO/YTE7i+p3faRKqvQZgvwmajhgxiVAjW4= 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 5.10 478/717] clk: ti: Fix memleak in ti_fapll_synth_setup Date: Mon, 28 Dec 2020 13:47:56 +0100 Message-Id: <20201228125043.867723914@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@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 95e36ba64accf..8024c6d2b9e95 100644 --- a/drivers/clk/ti/fapll.c +++ b/drivers/clk/ti/fapll.c @@ -498,6 +498,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) @@ -520,13 +521,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