Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2842048pxb; Sun, 3 Apr 2022 23:48:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDCoHDAI1dqbBLX7D8NQKUW+4UOQ9uAtJqQ9lmVLF9BWV2mTaCasJSDiWriVZ8f8rnlMdu X-Received: by 2002:a17:907:7b92:b0:6db:71f1:fc20 with SMTP id ne18-20020a1709077b9200b006db71f1fc20mr9055574ejc.343.1649054894163; Sun, 03 Apr 2022 23:48:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649054894; cv=none; d=google.com; s=arc-20160816; b=fxOFKWvweEMCw7j9Ahpv5rICPACDWxCkW+dysDD1OGo9sKGyWdYGnV7SriD7/CKsrJ EOoQhdzUWsHskrqnx7ZQzR3qW4ntOqlrQih8+4x6VyWY06lU54qq9SCaY5c2tYpV0R3V LNqGvr1Bt+mBuwuVT0NI44Uioxh9TvFY2NIA0DaX9CixFalXyiGtTs/+j6BSc0Qu+ADp t5SKtkgUK8rcgkkE0GNUaf92YzsqBp2OpiOUPamH8coMn0IEFvmaw0KxAlMaSAWk5tH9 oC8f7KdYWlOTKThHp8kIiSNCesNTTMW2W/xnftxvURqGuzOdFh325JNY4GYlaSmGqMmh 0hPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=t/uxrWafaSD5EnT5QwWMjaFa+/9c7ciaXbOG1s2P/OA=; b=yMIrij5M10GCWqmsQxITiWw5wcVxnO3kj1LrsPLajdyyjbwF//trDAm6NpS3gLZ5QL oIe3udi13Don/gxJh1XTfwN7EUPO2Y9zeXNusrnTlOsNgDyJx2CtxdC63b1lTUxg1xe+ U+lsMdQBh8BXEqeaTdvYVjHfSabMIxpVtsXm+CgUiVTzf756BvX6HG/4wRoS25W4/q3G GZV/EcJ9sO5NGjC4+7zuvPATdDEOfBHosr2sfbnd/gI4QHZBZQxMaJcumE+WiqBbh3WP noRcRHQxBLY1P0uCEd6vXV2SM7gVuaLz6VG9IU1tPpuugqW8BK2Y0R2VlqW4NLymuAob ECyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=qpw3bnZH; 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=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y13-20020a056402270d00b00418c2b5bd33si6663295edd.21.2022.04.03.23.47.50; Sun, 03 Apr 2022 23:48:14 -0700 (PDT) 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; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=qpw3bnZH; 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=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353365AbiDAXPL (ORCPT + 99 others); Fri, 1 Apr 2022 19:15:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350461AbiDAXPJ (ORCPT ); Fri, 1 Apr 2022 19:15:09 -0400 Received: from alexa-out.qualcomm.com (alexa-out.qualcomm.com [129.46.98.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A02BEBA; Fri, 1 Apr 2022 16:13:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1648854798; x=1680390798; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=t/uxrWafaSD5EnT5QwWMjaFa+/9c7ciaXbOG1s2P/OA=; b=qpw3bnZHIqMksDumE/FzG29z4HPvjDVJnI0/68ECk2NExzlDhpbyHb8/ fJhN+vBFesB082aynXEwwmUKkZyuD16DBfgAEuVJnZfZssUxNmIirkCSF 5liMwz/3KCWGF3BRLHTJY9dD/IjKUYI3KcrYZe56OllSQqbTuIK5D0hLj s=; Received: from ironmsg08-lv.qualcomm.com ([10.47.202.152]) by alexa-out.qualcomm.com with ESMTP; 01 Apr 2022 16:13:18 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg08-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2022 16:13:18 -0700 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Fri, 1 Apr 2022 16:13:17 -0700 Received: from [10.110.67.71] (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Fri, 1 Apr 2022 16:13:16 -0700 Message-ID: <275930a5-6f6e-4a93-6ac4-d5f99075d672@quicinc.com> Date: Fri, 1 Apr 2022 16:13:15 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH] ice: Fix memory leak in ice_get_orom_civd_data() Content-Language: en-US To: Jianglei Nie , , , , CC: , , References: <20220401080051.16846-1-niejianglei2021@163.com> From: Jeff Johnson In-Reply-To: <20220401080051.16846-1-niejianglei2021@163.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On 4/1/2022 1:00 AM, Jianglei Nie wrote: > Line 637 allocates a memory chunk for orom_data by vzmalloc(). But References to lile numbers don't age very well. suggest you s/Line 637/ice_get_orom_civd_data()/ > 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. s/We can fix/Fix/ actual patch LGTM > > 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; > }