Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp13070911pxu; Sun, 3 Jan 2021 00:44:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJwYpMQCAIGkosZzA8w0LVIJLe0FeytKlN64Ld6YjXzrnd4U+4NzO0CjjZoR1oSmSNaJWMEk X-Received: by 2002:a17:906:2b1a:: with SMTP id a26mr43699960ejg.23.1609663499505; Sun, 03 Jan 2021 00:44:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609663499; cv=none; d=google.com; s=arc-20160816; b=rJKhMPd5Q7e6do5ZI3qsglkcWkzp7Mo8ZPIkxIv+IsTPAsSYNKgAJ6IbVZfh3Qh3+U ILwsLlcFL2PB1S42x+jSedJ4E7isycJDnEuGK8egU8F8tyq6Sijj2ESspN2ejsCQjvXJ WHW6K03OT5IHj9kH5bpmFgw6CiL1BvvHYGkpjhQOaDr3VhgcHmXYEH7mCTmZRANY1FSb 7ir8WahfwtH0ZQkT3t5cspERAFK6vJG/CanzPFkBkKSohL/HqfzOT3ehGD/jD1HzfFZj L3/kR9PeSGg1Ymya4MXZQqR1jalhRS6M2jcOY/hpsg5SxRbvG0v55gl8nGWErh5nP/m/ oIvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:cc:from :references:to:subject; bh=jTFytKxMzMVCfnC+0CJCmdf7dE8SU/d/eS/hWnud2WU=; b=bOf17gxds9W5gb3BFGGGB0KV4jtRt1izH5IQOVTTSR1L86eV/YfFZ2UYsJMQzul8xa RfJ1qoDRcBZeBhRIaistsprzz7cSsIdB6hR4yifuavpuiV5Obs0ZB1AjyArgGFJIUYqP mMXIKMtMSJ4nVEQhKEf8L8yXhKanuD68kvp1ese29f2QVnNzYyANLeCx9OM4C9FgN2ia YeWQhTT3an4grzc40sj7Y6aAQ3s9kK+IAqdQXkvMsQ5jpBYaBcLYvNDjOCaYmgK69Ste oIfpqnue7ny2+zYflCV4apUTUyiofs6J/WMHQZvkdC2gQU8gNf2va+nhZqT85gNBjKKP YKCg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q4si29005491edg.1.2021.01.03.00.44.15; Sun, 03 Jan 2021 00:44:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726236AbhACIlo (ORCPT + 99 others); Sun, 3 Jan 2021 03:41:44 -0500 Received: from mx3.molgen.mpg.de ([141.14.17.11]:38179 "EHLO mx1.molgen.mpg.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725829AbhACIlo (ORCPT ); Sun, 3 Jan 2021 03:41:44 -0500 Received: from [192.168.0.6] (ip5f5aeaad.dynamic.kabel-deutschland.de [95.90.234.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: pmenzel) by mx.molgen.mpg.de (Postfix) with ESMTPSA id CEF6B20647B6A; Sun, 3 Jan 2021 09:41:00 +0100 (CET) Subject: Re: [Intel-wired-lan] [PATCH] net: ixgbe: Fix memleak in ixgbe_configure_clsu32 To: Dinghao Liu References: <20210103080843.25914-1-dinghao.liu@zju.edu.cn> From: Paul Menzel Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, Jakub Kicinski , "David S. Miller" , kjlu@umn.edu Message-ID: Date: Sun, 3 Jan 2021 09:41:00 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20210103080843.25914-1-dinghao.liu@zju.edu.cn> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dear Dinghao, Am 03.01.21 um 09:08 schrieb Dinghao Liu: > When ixgbe_fdir_write_perfect_filter_82599() fails, > input allocated by kzalloc() has not been freed, > which leads to memleak. Nice find. Thank you for your patches. Out of curiosity, do you use an analysis tool to find these issues? > Signed-off-by: Dinghao Liu > --- > drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c > index 393d1c2cd853..e9c2d28efc81 100644 > --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c > +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c > @@ -9582,8 +9582,10 @@ static int ixgbe_configure_clsu32(struct ixgbe_adapter *adapter, > ixgbe_atr_compute_perfect_hash_82599(&input->filter, mask); > err = ixgbe_fdir_write_perfect_filter_82599(hw, &input->filter, > input->sw_idx, queue); > - if (!err) > - ixgbe_update_ethtool_fdir_entry(adapter, input, input->sw_idx); > + if (err) > + goto err_out_w_lock; > + > + ixgbe_update_ethtool_fdir_entry(adapter, input, input->sw_idx); > spin_unlock(&adapter->fdir_perfect_lock); > > if ((uhtid != 0x800) && (adapter->jump_tables[uhtid])) Reviewed-by: Paul Menzel I wonder, in the non-error case, how `input` and `jump` are freed. Old code: > if (!err) > ixgbe_update_ethtool_fdir_entry(adapter, input, input->sw_idx); > spin_unlock(&adapter->fdir_perfect_lock); > > if ((uhtid != 0x800) && (adapter->jump_tables[uhtid])) > set_bit(loc - 1, (adapter->jump_tables[uhtid])->child_loc_map); > > kfree(mask); > return err; Should these two lines be replaced with `goto err_out`? (Though the name is confusing then, as it’s the non-error case.) > err_out_w_lock: > spin_unlock(&adapter->fdir_perfect_lock); > err_out: > kfree(mask); > free_input: > kfree(input); > free_jump: > kfree(jump); > return err; > } Kind regards, Paul