Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7119725rwb; Wed, 23 Nov 2022 02:23:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf6vyVMy5Wur4CZZIuW2V4PQNUgjMs5gMO1cEqUtUerMRSb0k9H9IaJL3zTgmPoGpyOdyWM+ X-Received: by 2002:a05:6402:2217:b0:468:fd95:eb4 with SMTP id cq23-20020a056402221700b00468fd950eb4mr14187218edb.230.1669198996835; Wed, 23 Nov 2022 02:23:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669198996; cv=none; d=google.com; s=arc-20160816; b=JzhefkZpft2U/k+VEMJUN05WdA/7yQv9RqcAUCD6M+fMi/llHHY335UoiO7lh+tRcC 4DV/7TD2kWyZMmsq/IDJMlJJwgqzqTiTVwVRGTVFxVij+j4PCZLsX87zdoKTMFeHp/El rLFwU55NEX69W+hIQztjw267uHXxeU720L08CVafytUkzPflXysNTtk7KrgmJXBVujTg 2cWtnU15UBb+9DJqYqepyvo/dO5v72RqOZ88uBDSHjGKy0CmmNsYUklNJIcQHU0G0llT lZOOUecqplpXvezwMCOqBh1EMg7+InxcbeQLoD6ue+b61xkNP6jHD5JRjFB83Mv5BHNz 81OQ== 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=54jlT1GxN7z+rD4XiG4nTxDxtk0/RWSwNKiy+p2uLbA=; b=Ktgcgw75B9aYD+w94+ecbYlEEsDl/jYxWAX/xoWZEPKvJLR73gEL2tZpe5mVpbmNtP 8bWMHUETsTQ7T+9/UQfJ7yz3LF5cW++hMBuRBiAtID3RhVMpmI/LHRus0dVSREfgNaBr jTA64nqX3rOqieHMeUiaSYQ8yTTwjgLtrzm2TnSXAXuNhyxPEw4uELR8WCVHLSx6WFHI LrE0FrAHn2wb8Og4m/jGlqFuHGoAHelGIDq5+jATIcYjDWdbi8Pih9fsJZyLGQ7+S7p2 NaKBpY/S6UQ6fjhhPIGP+VUbUjEHlvPiZUI689875IGdEgjrH5bCdTm86Y656zii419k V8MA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ji15-20020a170907980f00b007acbaeed9besi15696279ejc.398.2022.11.23.02.22.54; Wed, 23 Nov 2022 02:23:16 -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 S237279AbiKWJPO (ORCPT + 88 others); Wed, 23 Nov 2022 04:15:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237271AbiKWJPI (ORCPT ); Wed, 23 Nov 2022 04:15:08 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F92A87578; Wed, 23 Nov 2022 01:15:06 -0800 (PST) Received: from dggpeml500023.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NHFnP2GyFzmV6V; Wed, 23 Nov 2022 17:14:33 +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; Wed, 23 Nov 2022 17:15:04 +0800 From: Xiu Jianfeng To: , , , CC: , , , Subject: [PATCH v2] clk: rockchip: Fix memory leak in rockchip_clk_register_pll() Date: Wed, 23 Nov 2022 17:12:01 +0800 Message-ID: <20221123091201.199819-1-xiujianfeng@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.174.58] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) 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 If clk_register() fails, @pll->rate_table may have allocated memory by kmemdup(), so it needs to be freed, otherwise will cause memory leak issue, this patch fixes it. Fixes: 90c590254051 ("clk: rockchip: add clock type for pll clocks and pll used on rk3066") Signed-off-by: Xiu Jianfeng --- v2: move kfree(pll->rate_table) to the err_pll block --- drivers/clk/rockchip/clk-pll.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/clk/rockchip/clk-pll.c b/drivers/clk/rockchip/clk-pll.c index 4b9840994295..2d42eb628926 100644 --- a/drivers/clk/rockchip/clk-pll.c +++ b/drivers/clk/rockchip/clk-pll.c @@ -1197,6 +1197,7 @@ struct clk *rockchip_clk_register_pll(struct rockchip_clk_provider *ctx, return mux_clk; err_pll: + kfree(pll->rate_table); clk_unregister(mux_clk); mux_clk = pll_clk; err_mux: -- 2.17.1