Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3532942pxb; Mon, 4 Apr 2022 20:12:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxj12qU09spPvpqaWdnFlXXehHFZ00TC5bXSMA0bvOPTofHqsr9t+M9bU1RRA0e198gXzHy X-Received: by 2002:a17:902:ec8b:b0:154:5c1c:bc8 with SMTP id x11-20020a170902ec8b00b001545c1c0bc8mr1262261plg.154.1649128326332; Mon, 04 Apr 2022 20:12:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649128326; cv=none; d=google.com; s=arc-20160816; b=aqt4Rr4fSB+mtbJAb++ML2AnUacdnYenNnyB11qTZijBgo6LFwjAbvpbNcyYtylLn5 ie6tubUAuMIonrlPrpRO4fEzhwnhwslcRchrYjO1OyJdGz8tQGrGVEv2DK06Gp3pyK8G 6Lpiqyib6cnhAdDvs5E5J+O2R2z4L+ogAKnmTcbU4hsOlZsMFyHVGrkDK3+jJbdpnNZG tRizbeaSW8o1gbOvUV9U187eF5XjFB3ooccdePuGc+g5OCqqBG1mZZcHpy2q8H+Fl7ri c3ibZd1YWDToHlvHEv6FZqC+/nWJpbbQuwMTt4N6Ua6z/sMYRTdizvSO8GA+/EH9rpQ6 5dBg== 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=BINrCNBNH44euvnshLFjjJf4FagiFC3JLY+4VjHPKL8=; b=ay+XhtTEcPpDZgHPuYIMIwjp3ZTrhxSsUU0C2Vft57RO0EfKfPgrVfV7JLKaWxVVnP I/3CjcwBzDvSdD6lgJQciTgPIktPbuZ/wmV7rg1ikO+acfut95mQYseSdPf31fp2Ewt2 fqnC+rMWkTN6pGGGfBRsklSn3b9xqGkm3dE64QRrdVv4vcCkZghHT7zch4yiKOj3Ve/3 DxiYH7XZ1XffXHUr9OKoy3XkFY7anva425PGEPNvipprsGclP79zYcn5D9Fcf8cY92SL 2mU6/Tlsfzn6xzIRVZlrGqO54tzFwgrVZ46YKCSmnzTlW4l6bPCv183QVMiICiLpLxxO VLVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b="Vz+Zad/M"; 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 k3-20020a6568c3000000b003816043f01dsi12068417pgt.530.2022.04.04.20.12.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 20:12:06 -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="Vz+Zad/M"; 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 E8C2E17667C; Mon, 4 Apr 2022 18:12:27 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234560AbiDBCTj (ORCPT + 99 others); Fri, 1 Apr 2022 22:19:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230157AbiDBCTh (ORCPT ); Fri, 1 Apr 2022 22:19:37 -0400 Received: from mail-m972.mail.163.com (mail-m972.mail.163.com [123.126.97.2]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5CEB120A381; Fri, 1 Apr 2022 19:17:44 -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=BINrC NBNH44euvnshLFjjJf4FagiFC3JLY+4VjHPKL8=; b=Vz+Zad/M0vsawnPWVgkqK /c+k91Ifj1zun7LHfDYmuArkwVK78gTiClRy9VrHucLD5fDGn1s6bSyOEZ1CK6dQ YUGKcWLC5GQntclMK0PBjOjEWIWC3DniZmIon3h2Qnks/HkBd4/sjgPe3pF6Hqy2 HGu00KW5k5DJdflkTuxFz4= Received: from localhost.localdomain (unknown [218.106.182.227]) by smtp2 (Coremail) with SMTP id GtxpCgCH7DktskdiqyxVAA--.10933S4; Sat, 02 Apr 2022 10:17:25 +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 v2] ice: Fix memory leak in ice_get_orom_civd_data() Date: Sat, 2 Apr 2022 10:17:15 +0800 Message-Id: <20220402021715.4740-1-niejianglei2021@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: GtxpCgCH7DktskdiqyxVAA--.10933S4 X-Coremail-Antispam: 1Uf129KBjvdXoWrtw17Xr48Zr1kGw1DGr1rZwb_yoWDCwc_uw 47XryfJrW5W3WFy3y5tayfua40vr1DXF95Za13tayfX345Cr9FqasYvrWfXr40gr15AF9r Ar43ta43C345tjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xR_yxRPUUUUU== X-Originating-IP: [218.106.182.227] X-CM-SenderInfo: xqlhyxxdqjzvrlsqjii6rwjhhfrp/1tbiQxXWjFc7YXss4QAAs3 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 A memory chunk was allocated for orom_data in ice_get_orom_civd_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