From patchwork Tue Nov 22 13:36:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiu Jianfeng X-Patchwork-Id: 24380 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2206215wrr; Tue, 22 Nov 2022 05:44:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf6oH6MnECHqUgv55O/ViSZwvKEoC4qCoHF5KRKVWKi9MOs38X+JF53IO92fLAedVcDvenWA X-Received: by 2002:a17:906:2ccb:b0:7ad:9892:921a with SMTP id r11-20020a1709062ccb00b007ad9892921amr19172963ejr.506.1669124686019; Tue, 22 Nov 2022 05:44:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669124686; cv=none; d=google.com; s=arc-20160816; b=q8eKA+6j4IYOJ9X6dbbbzxP0RWp6MehKfM7rS8f34l94ivebDuDXKfk4C/NJzxDHne g22rnXX7Cm7L3u/Rd0Lx7phEtScon5Owem0hmatNihvsErMWJj+68P/d6RA1WZM82aOC hzzFaDcZexlK4w88OP5QCMPMDphQgwOuZ+hi8Yyin1hhYPUNPCIge1s/v8zelbBN09cM y0lj+PWlrFFmmjMXKOWS4iP8xzaPApon6WN7jRp1IoIDIZL3oTQ0OtRuweRpvWF7RaIv hzuyIfMDpZK4332pGKXPwMF0DNO7G68Ut2+Eb5CVPXT1iM4HIQ9o3drzNz+vy7LNvpBs 2usA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=VSphekkeATNynhZbTcBXpUGOf848SiC55LLkFdLNgJE=; b=xyvdVrXIeBKF4AxgeA0gnLTZ7mrdFnS1zKR3+1ax8pNyQifppoGoDlX+85JdVSgJ2m iFp03t/KRojrMPzTSHqnLq19Bw5VtqZZ/xdSjqtfdJZ3O0hdk4idWUTDDKFaJi+nNY4f Zc8OvasHrl+rZkzxEBRnLWgmjcUJw1tP1G+e98+gdfHCHat4Wd08XkKd4pIx3eYZD3sc K/vfdt6RPzd8TEboGBIGLPAddpPmhXJEBo7SMLMfSZW8fVg101rDEiuh9LNOp3JZ9sLv 0xyOn+UrYZby7wwj5C2ReBp6Ut+jNxQbpug2GyRPOwhV5xcz7AhrXsC8V9YwzrnWJi/2 vhhg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dt18-20020a170907729200b0078d550c0272si11636099ejc.269.2022.11.22.05.44.21; Tue, 22 Nov 2022 05:44:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233551AbiKVNj1 (ORCPT + 99 others); Tue, 22 Nov 2022 08:39:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233539AbiKVNjZ (ORCPT ); Tue, 22 Nov 2022 08:39:25 -0500 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2573359FE6; Tue, 22 Nov 2022 05:39:22 -0800 (PST) Received: from dggpeml500023.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4NGlhn2pcNz15Mpd; Tue, 22 Nov 2022 21:38:49 +0800 (CST) Received: from ubuntu1804.huawei.com (10.67.174.58) by dggpeml500023.china.huawei.com (7.185.36.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 22 Nov 2022 21:39:18 +0800 From: Xiu Jianfeng To: , , , , CC: , Subject: [PATCH] clk: st: Fix memory leak in st_of_quadfs_setup() Date: Tue, 22 Nov 2022 21:36:14 +0800 Message-ID: <20221122133614.184910-1-xiujianfeng@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.67.174.58] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500023.china.huawei.com (7.185.36.114) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750204086817107998?= X-GMAIL-MSGID: =?utf-8?q?1750204086817107998?= If st_clk_register_quadfs_pll() fails, @lock should be freed before goto @err_exit, otherwise will cause meory leak issue, fix it. Signed-off-by: Xiu Jianfeng Reviewed-by: Patrice Chotard --- drivers/clk/st/clkgen-fsyn.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/clk/st/clkgen-fsyn.c b/drivers/clk/st/clkgen-fsyn.c index d820292a381d..40df1db102a7 100644 --- a/drivers/clk/st/clkgen-fsyn.c +++ b/drivers/clk/st/clkgen-fsyn.c @@ -1020,9 +1020,10 @@ static void __init st_of_quadfs_setup(struct device_node *np, clk = st_clk_register_quadfs_pll(pll_name, clk_parent_name, datac->data, reg, lock); - if (IS_ERR(clk)) + if (IS_ERR(clk)) { + kfree(lock); goto err_exit; - else + } else pr_debug("%s: parent %s rate %u\n", __clk_get_name(clk), __clk_get_name(clk_get_parent(clk)),