Received: by 10.192.165.148 with SMTP id m20csp1264299imm; Thu, 10 May 2018 08:04:45 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqiYedmfjm5w7pXF5t5nOJ/R7P5RTQGJthkb+op64NoCxq7oGoUTgURpko9I3u63bsyxv6n X-Received: by 2002:a63:6e87:: with SMTP id j129-v6mr51458pgc.86.1525964685776; Thu, 10 May 2018 08:04:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525964685; cv=none; d=google.com; s=arc-20160816; b=E/Hi+2O5oxqzpA/z9tcHO7XmEbBNC52yQbU8wOZowVivNSTGMGF2NuY1Ao+0I8xm/J mNKRZfH/97SCjOaaFwDXCu+p47UzV0kq5qoSVlZglHxfcoI7tu1ctbRUgofkSznlfxaw muZNCJ4hZuulG9lPokWIXumVWGN56YB7kXzC+3sspsx9eZM0NzdJCTTrQXgu7+X8+Yc4 4vBn924k9m8BJjulv0kB8MY0UFXWyz7BRv1Cb40uFiOavB/l+CwtT+OmX/qsppkPIgNc 3SGyqm9fP2ecwv3CQ4lRCWzTlEoG5OFUXECa8+3dOfzVQfn8ojCiDUoIuwVTqiTqhRH2 0VNg== 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=/2ZPQGzwvaOSbBGE4hyD7jvwNMwdOlni9/jTG12U+3o=; b=wUFbaASGL1iVRH5y3yaAD0a7+puTEghrc3Xwg3xWoWRx6q1busgzS9mbV9NDEprfGe cTxHtgzSSixslq8GXN0F7xpbNT5IUH6BRF2szJ63uyYdtHdC5U4ELtfM26AQY8KsolmG VZ4Zsk+hsufySOQGdFFOMGJoQTJgB0vWsGPj2KjLJcUx34OBY0h9/exfr1wSqao90/U6 sBB9VBFFLkBUrgXnGVZiSr9iYFUVrxCysnzBDwd7yKtrbGMZLvEc9YF/sujTQj9mmIbT 0fv8QUiJrx50thjB5KB8nC0s8p0xz84bK+sc/HbcVAVnS8hEiQhaD76lwnQTwMQennLs 8pxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@Mellanox.com header.s=selector1 header.b=eW20/TcC; 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 j191-v6si802663pgd.440.2018.05.10.08.04.28; Thu, 10 May 2018 08:04:45 -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=eW20/TcC; 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 S966140AbeEJPDx (ORCPT + 99 others); Thu, 10 May 2018 11:03:53 -0400 Received: from mail-eopbgr20061.outbound.protection.outlook.com ([40.107.2.61]:35040 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965215AbeEJPDt (ORCPT ); Thu, 10 May 2018 11:03:49 -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=/2ZPQGzwvaOSbBGE4hyD7jvwNMwdOlni9/jTG12U+3o=; b=eW20/TcCiEKDB/LIjcLWamGnGk5o/IqP+HQmFfYcFZi89fxqrJGG7yT80LapQOULui+4FPa5OdW6/v1Uu0J9bmlHX652Y72+sHQZ48dovKD+8zl/0pSZVZb26BuYklg0baZx8s7vc2S9OkJtUc0v90i6xjz2T2cDiRcVqxZ8oVE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=tariqt@mellanox.com; Received: from [10.8.1.14] (193.47.165.251) by HE1PR05MB3258.eurprd05.prod.outlook.com (2603:10a6:7:35::20) 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 15:03:43 +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, 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: <49d89081-95d8-e7ae-2903-372a201ff92c@mellanox.com> Date: Thu, 10 May 2018 18:03:36 +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: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [193.47.165.251] X-ClientProxiedBy: CWLP265CA0054.GBRP265.PROD.OUTLOOK.COM (2603:10a6:401:12::18) To HE1PR05MB3258.eurprd05.prod.outlook.com (2603:10a6:7:35::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(2017052603328)(7153060)(7193020);SRVR:HE1PR05MB3258; X-Microsoft-Exchange-Diag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D6sUH9DtdEz7zuYRfhDu6LzlCfqlqtGixsCAYhJON0kkp45zUhpn3D5q9uLYyYUG9nXIB5ZQY8MqlHIsJY78xMZuPq1JQzQ+CFTpTd6CKEpgGg2K/21Soqk1De3jSEExqVN1TiEyk1Hd/ab7cwz1uo094LC8roc16OME4pjKJVNt1GRrP0n/1nJQUhw/GNlDNssnSTJkYd25/XP1tTPgOFG37cDsxwF3W7ZL5iik49oprtIBJRulGaqX5YiolsK6vKDcX1C35jJq+fGDQz70oUZ56hNdMUYWIMtiFEe5HyIn0ekRpse6a7N0KSzXIPSeB9rqm/NWwp0xxKopxGrop9rWUchfDmKvc2ICMVFKYyEgZo0DRXqrlCm;4:KftcQzgKh+F3PJ4F49rL3/rcJPhlynuKwkf4qIXmW3rznbBGY9pPiQ+bR8O/e8bXUkEahMjzDQEbCvdz2aJufKt5sGWLXGEnuXe5cn0i5yrWqCXvcsRauq/Wx/HOTJCdRAvJaGibd1o+mh1q4rFSeJIXwXkqhwnLtu9oC2UEOPeTUAViqt2G+Y4pa4hbYtT/PcSbB9ZfN1GyLDtDGyFhSVxyid9bhy8LX4DNquto3o4z7jh8bCKHbpyIXDBBlf4Zpz6nCQCa3Sedv8nVEIDvVw== 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)(5005006)(8121501046)(3002001)(93006095)(93001095)(3231254)(944501410)(52105095)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(6072148)(201708071742011);SRVR:HE1PR05MB3258;BCL:0;PCL:0;RULEID:;SRVR:HE1PR05MB3258; X-Forefront-PRVS: 066898046A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6049001)(396003)(39860400002)(366004)(39380400002)(346002)(376002)(199004)(189003)(52314003)(31696002)(229853002)(15760500003)(110136005)(316002)(305945005)(7736002)(16526019)(67846002)(478600001)(68736007)(16576012)(58126008)(8676002)(11346002)(446003)(956004)(476003)(486006)(2906002)(2870700001)(2616005)(186003)(93886005)(86362001)(65826007)(8936002)(36756003)(53936002)(81156014)(5660300001)(81166006)(6666003)(65956001)(65806001)(105586002)(66066001)(26005)(386003)(6246003)(53546011)(76176011)(97736004)(47776003)(4326008)(31686004)(64126003)(6486002)(52116002)(25786009)(52146003)(77096007)(23676004)(2486003)(50466002)(6116002)(3846002)(106356001);DIR:OUT;SFP:1101;SCL:1;SRVR:HE1PR05MB3258;H:[10.8.1.14];FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtIRTFQUjA1TUIzMjU4OzIzOmMxTmJsM09BTjF2K1JEZkdvcmNEcTZRRUVX?= =?utf-8?B?UFlVbVZkb1g3ZEc0NytRWnJpNklXNjdwSTlZL2FYQzVyUU83cXdnL0hrZE5F?= =?utf-8?B?Z1l2eGNCdTBBS3JWVnVTWitqS2tBWFhBVmNvY0RGTFVsWUJaRzRZTUM3eUQ0?= =?utf-8?B?V3J5ZGd3MmUyblF0STB2VU9DMVB0K2I0d25VSnFvSVhBVVpISHRGcFpZd2ht?= =?utf-8?B?Z08wYjB3endJM3F1Q0ZoV3d5eG9RSHZBNy9Kb3duTDZvbWZaZmZmUXZIOU9Y?= =?utf-8?B?Ly9vcWRsWndnUXV1dEdVR1llK2RkRHRJNFB0cDhLQnFzOGtickhYZnBYK0Nx?= =?utf-8?B?aGF3dTAvR2NSV0F2eUFWQnVMUkdCL3FucmZRUlF3NTBhRjBKTURpUHBUeDhr?= =?utf-8?B?TWhDb0tRaDBEM3hsUlZoU3VZTjAxZUoycGZqMU1PMm4wUDBxNDYvYy9LaS9K?= =?utf-8?B?K3FBRE82UVNLa2VJQ1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UZHS X-MS-Office365-Filtering-Correlation-Id: b414e921-df7a-4847-60bb-08d5b68739bb X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 May 2018 15:03:43.8058 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b414e921-df7a-4847-60bb-08d5b68739bb X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR05MB3258 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/05/2018 5:36 PM, Tariq Toukan wrote: > > > 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. Well, the flows in which we need to nullify the tx_rings pointer (if any, I still need to investigate this) is not related to this init function. Here we're safe. Anyway, a V2 is already submitted, please use it for your next comments. I think patch is OK.