Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3424516pxb; Mon, 4 Apr 2022 16:34:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxldnXp6UghdWTOuaVJXcEAqaG1zrwf++ououjVmq9+JRq8NXQgeIRJ5Row24gIM86hGwT/ X-Received: by 2002:a17:90a:c083:b0:1c6:a164:fd5d with SMTP id o3-20020a17090ac08300b001c6a164fd5dmr833439pjs.8.1649115266302; Mon, 04 Apr 2022 16:34:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649115266; cv=none; d=google.com; s=arc-20160816; b=ZQ09zzZD56acdlyYWGUE+4/M14a6Layb4y4TxKXoBXCh3tMO/obtxRGtMXLy85tGsz PuAEpOc1QoNUCxA5RybH2YEs8OErSMnwXzHMrkqj145vGxz16gzQu9/TcVC4dE09r2Rf zhllb2Px52Hw/117dtCQAXXkVcqUZBmHp1YNOZ9IFU6WeVh94fO35X/5SaLaXmHKFUeI Njy1aDf0DIieOz/+nUvE/bP+uu5tjqARBq8M0p1wwkN/GYhDClUyrO3Ob2piRcGgesf+ wl/3ki9gn3j0KAMKsXHwYfAkDPAu80RhjjWIVJgdL7RPiyQCGAKDSZmC28T10p2fySAV pdCQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=JUc46HYuLiqd9LVyi4hFXB41fWVvcsco2nwyplr06aY=; b=gJ+lhjYPlEgorTXlZh5EsW+l13gZAt2M6Igq6nr5z/m8pgijsLuC/pZu1r8RYc+5iF PsbW2QTmKJrFRuPT5iwRkDO7n0c4SrEt00zVFtNwC2EnosrstpTX75Zog69Mqk2RiGXD rjPzdK/pElynXYS09RziYN4JmulFB16Sy9AMuUoaDeJuj5FjQ4QXXTK0S4J9CC7lbpaQ KA25krpwSJhwLiFYRZuO3xSHd8AZTF9z1ABu4Th4w3atxhZ5pwdMRPychXuOuvaAADWg oEzNHLslGwYuPjn7SQfvqiaKQLMvJ/FHm/09IqG4YzIMqHBueoV2lCB8JJJW7YupqV2X d8cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=csG42RSP; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id k65-20020a633d44000000b003821ef6f3bcsi12404556pga.365.2022.04.04.16.34.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 16:34:26 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=csG42RSP; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 C52122BB2C; Mon, 4 Apr 2022 16:29:16 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344087AbiDAIDW (ORCPT + 99 others); Fri, 1 Apr 2022 04:03:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235271AbiDAIDS (ORCPT ); Fri, 1 Apr 2022 04:03:18 -0400 Received: from mail-m971.mail.163.com (mail-m971.mail.163.com [123.126.97.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 24A131C8D8C; Fri, 1 Apr 2022 01:01:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=JUc46 HYuLiqd9LVyi4hFXB41fWVvcsco2nwyplr06aY=; b=csG42RSPrqWtd1oel1QRR zKmpHz7cN2eYLXAN5Y+PQ2/eurmSwZHUO3t7ocST0HBaOykqfhoxdeXeKZ1eb3Pb PLORxWU9vE1qnG8nN4U5e+pbfHyefNi7P895pxGe762uqFAfPLyKL+m8dYwLvjLs 0Y6LZxSfrLn7x72WKcRF6A= Received: from localhost.localdomain (unknown [218.106.182.227]) by smtp1 (Coremail) with SMTP id GdxpCgB3NWo1sUZiKRQTAA--.3770S4; Fri, 01 Apr 2022 16:01:09 +0800 (CST) From: Jianglei Nie To: jesse.brandeburg@intel.com, anthony.l.nguyen@intel.com, davem@davemloft.net, kuba@kernel.org Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jianglei Nie Subject: [PATCH] ice: Fix memory leak in ice_get_orom_civd_data() Date: Fri, 1 Apr 2022 16:00:51 +0800 Message-Id: <20220401080051.16846-1-niejianglei2021@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: GdxpCgB3NWo1sUZiKRQTAA--.3770S4 X-Coremail-Antispam: 1Uf129KBjvdXoWrZFWUWw4kZFW5JryDAr1UZFb_yoWDWFXE9w 42qryxJrW5W3WFy3y5tayfu34Fvr1DXr95Za13tayfX345Cr9FqasYvrWxXr40gr1UAF17 Ar43ta43C345tjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7sRtOJeJUUUUU== X-Originating-IP: [218.106.182.227] X-CM-SenderInfo: xqlhyxxdqjzvrlsqjii6rwjhhfrp/1tbiDw7VjFUMcc6wYwAAst 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 Line 637 allocates a memory chunk for orom_data by vzmalloc(). But when ice_read_flash_module() fails, the allocated memory is not freed, which will lead to a memory leak. We can fix it by freeing the orom_data when ce_read_flash_module() fails. Signed-off-by: Jianglei Nie --- drivers/net/ethernet/intel/ice/ice_nvm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/intel/ice/ice_nvm.c b/drivers/net/ethernet/intel/ice/ice_nvm.c index 4eb0599714f4..13cdb5ea594d 100644 --- a/drivers/net/ethernet/intel/ice/ice_nvm.c +++ b/drivers/net/ethernet/intel/ice/ice_nvm.c @@ -641,6 +641,7 @@ ice_get_orom_civd_data(struct ice_hw *hw, enum ice_bank_select bank, status = ice_read_flash_module(hw, bank, ICE_SR_1ST_OROM_BANK_PTR, 0, orom_data, hw->flash.banks.orom_size); if (status) { + vfree(orom_data); ice_debug(hw, ICE_DBG_NVM, "Unable to read Option ROM data\n"); return status; } -- 2.25.1