Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2073420pxb; Fri, 25 Mar 2022 10:36:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxuTZc2WUMijuGTcFU/k6H2o/vDc7Kv/TsBanjSjwd8Nqg1zf7RikBI0DJN28nWJrnqFPwJ X-Received: by 2002:a17:90b:350f:b0:1c7:7769:3cc6 with SMTP id ls15-20020a17090b350f00b001c777693cc6mr13787376pjb.120.1648229775398; Fri, 25 Mar 2022 10:36:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648229775; cv=none; d=google.com; s=arc-20160816; b=HDipgc9kh3kGyYLzXvxnVhbEpyglS+P1TOR5SAEAtxgv4N9ajAccbaMBjVjeRbmUBi 11uIgWOwFQ+AWehkG1QM38N1S2pF/Qsi3MWrTkBsW+zVXN3wEuObS/+zwjwG4YwGFwRE 8d50YEJM6dXL6XDVf/copmgrAtlaWbF2Q3W04iIOGVHxlgftkb663pwXpz+23SrGoTGy L2mo+rXTGCBBzydUnutcf6Inw6KGi5Vw5MiAqqdF7+05+ik2Z5PYHDBwtoDaw69hugkt aQd8Jza5iQUX+Kg5SMvObQh65X9LtxCAOFhFkDkLOMP1CAZkGV2lhkY6wXCl3LIP3AKc VbYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=X2PkbZuSv9BM7e1K9tz2R+SePk62dCZezpam7namyVY=; b=EFa3gtVVRJSFWxPLmArwMAKhlLNm+iFCVTVrJL/NVwl1szgC6Z2xs1DOCxcMNjogJ7 Pl10OOb7JS9n/33m1jCD6A+a9XZ13u95r1ncE89VN4rcxO/N432JJtImO4zv0Dv9RiQd O3QrtA5KfL0Dt7BQKP0o+EqERQvWqHe0YcON83JEnxeXwerA8Flz/CP7QOAIlXcT0Saa ypVIXvc6CTNOjdcHMhlSrTI0d0UY8R/V32cQ+tvo3RSVLWA5iIvisnfVMA2lTXUCfngh Ws3xzf4dS09WYEAkNZCMd3KBdMZbYSWrNi0vTZfERVaX6ZSsKMArDytiDQvqc4BGlu+M zEag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=RtMkhZh2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id c4-20020aa78e04000000b004fa7103f312si3054832pfr.68.2022.03.25.10.36.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 10:36:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=RtMkhZh2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 07E3610E570; Fri, 25 Mar 2022 10:24:54 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348894AbiCXIXc (ORCPT + 99 others); Thu, 24 Mar 2022 04:23:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240325AbiCXIXb (ORCPT ); Thu, 24 Mar 2022 04:23:31 -0400 Received: from m12-16.163.com (m12-16.163.com [220.181.12.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 360D19AE74 for ; Thu, 24 Mar 2022 01:21:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=X2PkbZuSv9BM7e1K9t z2R+SePk62dCZezpam7namyVY=; b=RtMkhZh21Q/LFBYdsgq3eTqWEKIu73tDrS u9hQiWZyU4fA3zf3inWnhUrh8H0HmfraMpgu0W3LIAaSHCOR5QkVM3HujlHlKzmB 5oD2rdvKPqmKtjsrl8peyXYLJHV9DpMGUYsb92E3+wd8kVxDzuzMYde8ZVyPzWBE vLr7M+/9Y= Received: from localhost (unknown [159.226.95.33]) by smtp12 (Coremail) with SMTP id EMCowAAn5B1iJjxiNR7tAg--.21428S2; Thu, 24 Mar 2022 16:05:54 +0800 (CST) From: QintaoShen To: dinguyen@kernel.org Cc: linux-kernel@vger.kernel.org, QintaoShen Subject: [PATCH v1] clk: socfpga: Fix a potential memory leak for kzalloc() Date: Thu, 24 Mar 2022 16:05:53 +0800 Message-Id: <1648109153-32756-1-git-send-email-unSimple1993@163.com> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: EMCowAAn5B1iJjxiNR7tAg--.21428S2 X-Coremail-Antispam: 1Uf129KBjvdXoWrtry3JrykWw1fZryrWF1kuFg_yoW3Xwc_Wa 4jgr97Wwn8CrWUCr1qy3Wavry0kFs5urn5XFnaqw43Ja4ruF1UAFW2vrs5Wr1xKrW09ry3 Zw1UAr17Z39rCjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7VUUzBTUUUUUU== X-Originating-IP: [159.226.95.33] X-CM-SenderInfo: 5xqvxz5sohimizt6il2tof0z/1tbiNALNH1aD-KonPgAAs+ X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 kfree() is missing on an error path to free the memory allocated by kzalloc(). Signed-off-by: QintaoShen --- drivers/clk/socfpga/clk-gate.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/clk/socfpga/clk-gate.c b/drivers/clk/socfpga/clk-gate.c index 53d6e3e..0ca5e00 100644 --- a/drivers/clk/socfpga/clk-gate.c +++ b/drivers/clk/socfpga/clk-gate.c @@ -188,8 +188,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) -- 2.7.4