Received: by 10.192.165.148 with SMTP id m20csp1163346imm; Thu, 10 May 2018 06:40:10 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq4RX77KuB5cBEWdrN5Xz8ynPPxuMk4PkaYspqLQ3WX2Sny2B7yHskMH4hccAODqg7f4bJ7 X-Received: by 2002:a17:902:b902:: with SMTP id bf2-v6mr1423256plb.37.1525959610798; Thu, 10 May 2018 06:40:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525959610; cv=none; d=google.com; s=arc-20160816; b=WvUvsdiFXMC5ETxwGcZ2Pozv/p4YyWvLCKBoeH2OSVX55wpTn7n3fqAKI3YA1A31La JhoEraM745QuRYc5beJpfRD1VXtM0JG3hUxRzzkgsS44dF65sDIY0NlXd5CBH89kNAYa LMnqS9xsHpGW0sCGr6xqyV72Ik4gkXd5JqqbmEt/XTLkCeF/0IsZc1vN+9Fm81plTGs0 fl0Kvl2cAKYcKj7jePLBo3QNek+HkMmkcKHzP2fLaRenTqbCFQEvV69hsld6HOCFi/SG GMtPHHYx5JQu70LLc+EioBieJXGPbvty+Lato7vFe2rP+QcnXRuzDPyKHGRGniQ3yt33 5iyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=MoIooJ7wVRDh3JxytZH8UVdsTn3HTVez1F4VofxPrrk=; b=0jQnBZGwPuAvdcROnZjcY/U9SBkbmb7qeCoX1pPQifgZAkOMXjfbnL74NlvAihjrVK OI5ItNGcuTISQDd2TZtR0Xm1EARCpjD4aKWf8G1HukZu9LMQyNBZJGhXQUFGneReg5um eiC447OiPy/PHJB1tkTJRbtZ5y97iL8mIlpbdg1v2vmNOxa18FWjohzqT9EFteeHMBbI 3y8uUzJwr1r+mCPqyzRpLwfiizwusMmuroYGKwDMoilXmOqX3qqfk+nLNVf3sSfi51Xj Q3W92UTYvqzl4wiWZLm66Rpjkvf6kfgtEC4oo7DvnRBbCxQbkEhwlnPQk7jfhC2jmcH7 TqOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=O0zghDvv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a92-v6si769189pla.291.2018.05.10.06.39.55; Thu, 10 May 2018 06:40:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=O0zghDvv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935639AbeEJNiW (ORCPT + 99 others); Thu, 10 May 2018 09:38:22 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:36314 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935499AbeEJNiU (ORCPT ); Thu, 10 May 2018 09:38:20 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w4ADZfkn071601; Thu, 10 May 2018 13:38:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2017-10-26; bh=MoIooJ7wVRDh3JxytZH8UVdsTn3HTVez1F4VofxPrrk=; b=O0zghDvvM+VgBITklJasYZK79fS4P3nSZ1SuEZafKspMueCn0rlo+/K7YUbmea5Prsq6 +20V6j/rTp3wFa5idqs98y20poFPPqKT5YhSElH4HNBJ/N122yw2eTrrBQMlH7htJuv8 qOJtMWQjr9Ww/aFln7L/ewVpfALj4G1Q1OGK5TuWpdKOlTsSSZ8AHGtO8nnboGO6RnSi GcWiq6QWtIySANEJ/8cEPbyuRUVQu+dogATngUhLP+Nc8uNxnskvSRIdcNsgwDxq8TNU y3ykz85AcVx8LUX0gG5GR6MOvqMl+ixF8n/gZ4NDc1TQRokwo2bxy2KtPqn1DE5TiZ3V Ng== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2hv6kp3mb9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 May 2018 13:38:15 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w4ADcEwq025243 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 May 2018 13:38:14 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w4ADcEUN025472; Thu, 10 May 2018 13:38:14 GMT Received: from lap1 (/10.175.25.164) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 10 May 2018 06:38:13 -0700 Date: Thu, 10 May 2018 16:38:08 +0300 From: Yuval Shaia To: Christophe JAILLET Cc: davem@davemloft.net, tariqt@mellanox.com, netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] net/mlx4_en: Fix an error handling path in 'mlx4_en_init_netdev()' Message-ID: <20180510133808.GA10943@lap1> References: <20180510070226.19575-1-christophe.jaillet@wanadoo.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180510070226.19575-1-christophe.jaillet@wanadoo.fr> User-Agent: Mutt/1.9.2 (2017-12-15) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8888 signatures=668698 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=9 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=993 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1805100132 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 10, 2018 at 09:02:26AM +0200, Christophe JAILLET wrote: > If an error occurs, 'mlx4_en_destroy_netdev()' is called. > It then calls 'mlx4_en_free_resources()' which does the needed resources > cleanup. > > So, doing some explicit kfree in the error handling path would lead to > some double kfree. Patch make sense but what's bothering me is that mlx4_en_free_resources loops on the entire array, assuming !priv->tx_ring[t] means entry is allocated but the existing code does not assume that, see [1]. So i looked to see where tx_ring array is zeroed and didn't find it. Am i missing something here. > > Simplify code to avoid such a case. > > Fixes: 67f8b1dcb9ee ("net/mlx4_en: Refactor the XDP forwarding rings scheme") > Signed-off-by: Christophe JAILLET > --- > drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 8 +------- > 1 file changed, 1 insertion(+), 7 deletions(-) > > diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c > index e0adac4a9a19..9670b33fc9b1 100644 > --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c > +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c > @@ -3324,12 +3324,11 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, > MAX_TX_RINGS, GFP_KERNEL); > if (!priv->tx_ring[t]) { > err = -ENOMEM; > - goto err_free_tx; > + goto out; > } > priv->tx_cq[t] = kzalloc(sizeof(struct mlx4_en_cq *) * > MAX_TX_RINGS, GFP_KERNEL); > if (!priv->tx_cq[t]) { > - kfree(priv->tx_ring[t]); > err = -ENOMEM; > goto out; > } > @@ -3582,11 +3581,6 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, > > return 0; > > -err_free_tx: > - while (t--) { [1] > - kfree(priv->tx_ring[t]); > - kfree(priv->tx_cq[t]); > - } > out: > mlx4_en_destroy_netdev(dev); > return err; > -- > 2.17.0 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-rdma" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html