Received: by 10.192.165.148 with SMTP id m20csp1232761imm; Thu, 10 May 2018 07:37:42 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrmvZt0KwSi0riofea4KpM3p1F73IcFIsxK1GXKADVJLDK8TYqww/OKt8JPjTnDZ7sknH1c X-Received: by 2002:a17:902:14cb:: with SMTP id y11-v6mr1606606plg.229.1525963062146; Thu, 10 May 2018 07:37:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525963062; cv=none; d=google.com; s=arc-20160816; b=Kk1/H+A/VcHyCQAe0nLaER+Plvz/dM+X4xkUrWXyFbFkUSmfk2TPcOPCHi4NATsHlG cL8VlkjLmuPEnP1DqHscBmLSbW4/EdLovACq2Z8PQtJIfiYp65/3GXM/bd02M/9Rs9Uh fTUxbG8PeMd3/n05sqez37Wo+feat6kRHceE1W+4WlupUPWlvviqP7yjd/RHxK+cnGnS 4xrIGYkm0ugrLfX/1Sxngzd7jbabhatzY3m8rlVumScMh/9Sg+O4NacV4SlMzcKLeXoQ GUBqE/wO75ziQ/ZQ5rI/UDd7d3+hLtXsf+sRAYNV0lZ0gxQgMgDq0ziM188wF81yhTE1 aY3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature:arc-authentication-results; bh=G60SoynllLHgMkAqrnJ6H4HtiJ3X375Sy/nTWDEgF3A=; b=MFXDM9VybAJmWT4OSiSEuT+//gCsACU0rrPqRB49kA1WBSlkvrCiOGh4haG9r7RR/J S3rW38ezU31GEVUQv94sydcOKxd8qxPsF/jEiKYUut802o1z1EEjVEVf+u0ZQdcq0C5m kNtBZDXDWC67OX102cgqQB7CBUdSYsymdsqxSbrJeWCWJtZLP3zuC/dBbKPQFPtqUlRV +Gmlf09VqdbVKKjmasPcYln1yrPMC0RYQFltUWesaKG+kZvfBh3IL9Tf5RwAzlBCFTMm o6wqZQ3BFBVTCq6Yv5FkkHUYVi6fl+aWzhttTEHWbRA2KDqPe92qjka+2FP2W8MVdSBS WE4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@Mellanox.com header.s=selector1 header.b=wjLv0Uv+; 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=mellanox.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 64-v6si894901ply.528.2018.05.10.07.37.26; Thu, 10 May 2018 07:37:42 -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=@Mellanox.com header.s=selector1 header.b=wjLv0Uv+; 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=mellanox.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966119AbeEJOhJ (ORCPT + 99 others); Thu, 10 May 2018 10:37:09 -0400 Received: from mail-eopbgr20051.outbound.protection.outlook.com ([40.107.2.51]:23666 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S935438AbeEJOhG (ORCPT ); Thu, 10 May 2018 10:37:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=G60SoynllLHgMkAqrnJ6H4HtiJ3X375Sy/nTWDEgF3A=; b=wjLv0Uv+1BjVntizKxLXsLw7hamtewsto0sl8OcuTs93wXwiFNo2E05gbjOX5FZOSCHI382yuJ1s88Wbu1GxMWBOhz2b1hMP6PdF7kUp7OVvMT9dcxcNkd7mI8oMltJNPeAw4gHD+TeM0DkmG+z3ytiueDZpoS6U39la02XaUns= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=tariqt@mellanox.com; Received: from [10.8.1.14] (193.47.165.251) by AM4PR05MB3250.eurprd05.prod.outlook.com (2603:10a6:205:4::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.755.16; Thu, 10 May 2018 14:37:00 +0000 Subject: Re: [PATCH] net/mlx4_en: Fix an error handling path in 'mlx4_en_init_netdev()' To: Dan Carpenter , Yuval Shaia Cc: Christophe JAILLET , 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 References: <20180510070226.19575-1-christophe.jaillet@wanadoo.fr> <20180510133808.GA10943@lap1> <20180510141836.2qlm676j4675buti@mwanda> From: Tariq Toukan Message-ID: Date: Thu, 10 May 2018 17:36:55 +0300 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180510141836.2qlm676j4675buti@mwanda> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [193.47.165.251] X-ClientProxiedBy: CWLP265CA0130.GBRP265.PROD.OUTLOOK.COM (2603:10a6:401:53::22) To AM4PR05MB3250.eurprd05.prod.outlook.com (2603:10a6:205:4::19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(48565401081)(2017052603328)(7153060)(7193020);SRVR:AM4PR05MB3250; X-Microsoft-Ex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v8z7GMmlaI/Fsry/bnKXpBb5DWImld+XdTKSnkvEPb+zsO15ikZfSIpR127NzothMKMc1kE7O7QhsD3mQ2rVB8jCJ3oMgc4CBW2aNBQJ97/yuNl6v7p5uyHdYA2POCUndliV6vFD6BARFnzsLNip3g2maASHzm+1eioK3r+xJk1TeUvKdvJbQ9+172YydTg2Z0euJc3PO7sl/y5IMUhCs8oxtrZBjloZHKxG96Bk662iBkA+Zy0Q7huQ7YtXdhvAyGn2DRWU+k5lUCoG9EPgmTlR74VnAy4yfdLhOkG7MI28NimMING2883L/I5ymFBWUEksWcCTPgHwEewJxjf0qsF2q6AiyAGPq5JZh5/KZJmUAQIXBdC;4:bi/A+AzghZRykAsyNkvLwDS/UYbwbcd8R9J+L4v2uZyUpYdYFJyX+SOWPYRQMq6oQ70fKgUkWmMJ/XIwGLkoN3KhYGCr+wewSJvYzA9rfL+AATHTiclR2a9LhgRTD75/bYo+ngZ4MT9MbbRjWZ0UN+Tt7R87d0ID5m9puQTkhXx2/FXqonaYEIE5xltlHZzOMc7IagG28GwwB4CfunHbT/6uLvYrMSr+eT1k42qvT9BS/kQJjuLWSwUit4nUVY6sN0asNhEBiBgcevXtO9W4QQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(10201501046)(3231254)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:AM4PR05MB3250;BCL:0;PCL:0;RULEID:;SRVR:AM4PR05MB3250; X-Forefront-PRVS: 066898046A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6049001)(366004)(39380400002)(396003)(376002)(39860400002)(346002)(189003)(199004)(15760500003)(47776003)(478600001)(2906002)(52116002)(6116002)(386003)(81156014)(2486003)(52146003)(6666003)(230700001)(7736002)(66066001)(8676002)(3846002)(81166006)(8936002)(65956001)(65806001)(53936002)(106356001)(67846002)(105586002)(97736004)(76176011)(23676004)(5660300001)(53546011)(4326008)(58126008)(50466002)(26005)(25786009)(305945005)(77096007)(64126003)(86362001)(186003)(229853002)(16576012)(68736007)(6246003)(110136005)(956004)(11346002)(486006)(65826007)(6486002)(316002)(446003)(16526019)(2616005)(36756003)(31696002)(31686004)(476003);DIR:OUT;SFP:1101;SCL:1;SRVR:AM4PR05MB3250;H:[10.8.1.14];FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtBTTRQUjA1TUIzMjUwOzIzOnFDdkcyUWtYWXRadHFZWjk1ZzkraDAwS3lq?= =?utf-8?B?cGNnWk5BUmM2SUhnTGFUbmRDWW51YTJnODczZ21Gc2Jtc25Cb21TTjJBQ1RX?= =?utf-8?B?TE5LR1RyQlYvQk41VVoxeDIxNTBaSnp1VDZiR0pyQVFkTkRNbFdyRlNXQktZ?= =?utf-8?B?aFJuTElqK2tkRW9WWHNtWmtXak44RTFUSGk5OXJGS3JGb2c4TlFsUWsydk5C?= =?utf-8?B?Z0dTajBrRFA4RnhZbmJyVEoxSmxISEkrOXZwOHhSWHV0YUJUaXJrOTFMRGtv?= =?utf-8?B?dDlpSyttUUUxaXZVc2VQRmxjUnAzZE1KRmhwejhzTmdzVUIzNXl3L2kwVjNv?= =?utf-8?B?ZHZqenZMTkZvMmk1c09nRmNjNDNvU2NKRkl2ektOcG1MRkN6ZmxXRFQ1Wmkx?= =?utf-8?B?TklrL2N0K05NRUo1UHc4a1h5REpiMEJZT0tGKzRZWGR6eFp2bU1WOEFIYzZY?= =?utf-8?B?NzkySDhhaXBSU2VIWE83V0pUQkhQZGhRNTFiWnZFanRhTHdr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yzcJu5yxlNhpvtC7M0QTSI0nOyj80QZzi5H+diLONaq3IlUY2+G6VHhjYmGOT4efQuGt+CgnEYIEQ+z4mIuJc5w61fUV+PiB85Vli9N9SzkJTkzj1w06e4yIVt2SJftqwd+eyOW+WuhCJjqkC02r6NBKfs3fJZx8wVbYZHttkK2naN1082Zwd8gHpK4mHgdJRZpoVYjtqeTxyfVrw8ynZP9ZVj1Nq0WkbYFIbh5hPF6ADzXNKqLuVda04wzQH/QugUJRHk3qb44697xd7XA9+1SZt4bb1XOsH45FRZIl3unodfQtRDzgDrZu3ATBOWQavyyLSYtYfDz+LN5OX5fA6zamZUMYE1Yw==;5:XDnYDYi5qcR6rAqMtjZGPo9q4UIeupHbDs4ijeGlHt2hBE5wzR7AUmcscKM7nWjFBm0MaaPkqViyHocC3N2WN852yOBS9gsFM2dUcVwIp9uaDHXyeUFulza4u/kYTqOm9YRxcbdsK84A4yUXsKPbnf6bUzrZKT7bkc9+a+VFlNc=;24:797SGWQTTZRaSLCk1sWz4tdmolS9dPu0tMrZNZKdtiTed1CsYfviTsTHke3HGavpmTQCH2l59k0cVROKvEqT6Zp5bU0iF6NHjzed3LG0OxU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;AM4PR05MB3250;7:7REd6pAJLnn3QD3JPuI6TTxWzlbnhVLWlDsHhLGxwUWlqVjuij9fIZfYJevuJBFp/WWLHogWp5m2DgngtvmRkCVaaLnl4uDgkRQB5z0oSLNqPyAc2JArBl8xWom8SYml7O/4+MtIoQF9pJSAzA7VGqL2xTBQrNxx/eEHPp8jzuzB/hhpyTlUJ5zr+R9LXhzsS/doG4m9mtobVFAJetdTTJJyl746/O2LLyHCl0KDCw5wJlCvOv+15JaYCtvvrg3O X-MS-Office365-Filtering-Correlation-Id: 7a27e7a0-effc-4e68-9405-08d5b6837e5f X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 May 2018 14:37:00.8551 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7a27e7a0-effc-4e68-9405-08d5b6837e5f X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3250 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/05/2018 5:18 PM, Dan Carpenter wrote: > On Thu, May 10, 2018 at 04:38:08PM +0300, Yuval Shaia wrote: >> 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. >> > > It's zeroed twice. alloc_etherdev_mqs() allocates zeroed memory and > then we do a memset(priv, 0, sizeof(struct mlx4_en_priv)); > > regards, > dan carpenter > We do zero (twice) on init, that's right. But I think Yuval's comment is valid in case of the driver went into configuration change, or down/up, that reallocates the rings. I'm double checking this.