From patchwork Wed Nov 23 03:16:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiu Jianfeng X-Patchwork-Id: 24677 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2568032wrr; Tue, 22 Nov 2022 19:23:59 -0800 (PST) X-Google-Smtp-Source: AA0mqf6ZSQvInaOfO81B0SMwqizv0DVZlns2+oVLMlb6lvJwtUYlWTrekwZvvqgRcue0bYnnI7pb X-Received: by 2002:a17:907:c314:b0:78c:2b55:59be with SMTP id tl20-20020a170907c31400b0078c2b5559bemr3794320ejc.2.1669173839724; Tue, 22 Nov 2022 19:23:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669173839; cv=none; d=google.com; s=arc-20160816; b=szKpIC0MeAnzxoFXbLD0LA+slEjK3Xou5kFM2aMdCVtyGIJFibUweKLvo7+lCjFU56 MI/ptDmR364aF/ZVKiRzoHguG57fdTDriIJ61ORWvvstvgH7KeX0t/0ylIET2omE+PNi LDZ27xYknyyfa9gb93502Gqeo9laWdbKsuDM1qpAoLRMM5/CnwJlAxNNh6+y97Ly8p9w 9LDl0kd17wXnwhTvauf2lLj0KZwzVNFse9SBR0JXSVl+DZfZoYLHSyv8txZq/7BwZred BDbM4akCoyjonCA8DVQp5H9Hef0PNN/3rMw/P7mEVsIR/FuyG6XTbWmFknmHdi/b7dV4 7Ijg== 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=uk3sXXPuxBshW6wJ/CG5ThS5fstCl/oeP3hNRMXoiSg=; b=ucNeLqswsDe7C6rZLO3tpnTAaHTxgZYElfTbxcjsLMt+K5GLYIYnw/8jMdPxIS5j6h 5tvctzBucxqRS0kSVJ2YfmDqkJarIv5i8M9JEXXYJHk/YO898cZX7Xn2l8/R71VLObEp EoKMRMIPOq6tWvDzoX6XbCrgE7Iq8LOkfLWl5IIA8a9D9OIQ5ztUljcJXC6oVCASktfE t+I3ppHgw5Qkl4hXFWQ3cI8QiErHFCWnOeLLNaR4k8RDhaPJyatZpJ0V0z742+cP1bBv ZWI0bEVV+BtThJIu1Cm9jIjVCLItRtGeaA5C3G2OuBSioxDUD7Air6wmn2od1RkuVpwo ytLg== 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 hq6-20020a1709073f0600b007ae17fd2f19si3045080ejc.734.2022.11.22.19.23.31; Tue, 22 Nov 2022 19:23:59 -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 S235373AbiKWDTa (ORCPT + 99 others); Tue, 22 Nov 2022 22:19:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232723AbiKWDT2 (ORCPT ); Tue, 22 Nov 2022 22:19:28 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45D758D4B2; Tue, 22 Nov 2022 19:19:27 -0800 (PST) Received: from dggpeml500023.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NH5q639FwzqSYX; Wed, 23 Nov 2022 11:15:30 +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 11:19:25 +0800 From: Xiu Jianfeng To: , , CC: , Subject: [PATCH] clk: socfpga: Fix memory leak in socfpga_gate_init() Date: Wed, 23 Nov 2022 11:16:22 +0800 Message-ID: <20221123031622.63171-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: dggems703-chm.china.huawei.com (10.3.19.180) 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?1750255627971919270?= X-GMAIL-MSGID: =?utf-8?q?1750255627971919270?= Free @socfpga_clk and @ops on the error path to avoid memory leak issue. Fixes: a30a67be7b6e ("clk: socfpga: Don't have get_parent for single parent ops") Signed-off-by: Xiu Jianfeng Acked-by: Dinh Nguyen --- drivers/clk/socfpga/clk-gate.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/clk/socfpga/clk-gate.c b/drivers/clk/socfpga/clk-gate.c index 3e347b9e9eff..0c18c55edf8c 100644 --- a/drivers/clk/socfpga/clk-gate.c +++ b/drivers/clk/socfpga/clk-gate.c @@ -133,8 +133,10 @@ void __init socfpga_gate_init(struct device_node *node) return; ops = kmemdup(&gateclk_ops, sizeof(gateclk_ops), GFP_KERNEL); - if (WARN_ON(!ops)) + if (WARN_ON(!ops)) { + kfree(socfpga_clk); return; + } rc = of_property_read_u32_array(node, "clk-gate", clk_gate, 2); if (rc) @@ -182,6 +184,7 @@ void __init socfpga_gate_init(struct device_node *node) err = clk_hw_register(NULL, hw_clk); if (err) { + kfree(ops); kfree(socfpga_clk); return; }