Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp1626960iof; Tue, 7 Jun 2022 08:53:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfOb/4tDDINskgxs+mqHRhxnpjJH2/tRQ1W8fnJ7UOEgNmYNYJMKG3soAYsaOA6VDdtgaY X-Received: by 2002:a62:6407:0:b0:519:3571:903e with SMTP id y7-20020a626407000000b005193571903emr35414938pfb.30.1654617205864; Tue, 07 Jun 2022 08:53:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654617205; cv=none; d=google.com; s=arc-20160816; b=HYLEaCbHQNh6P1a8wx5bBpTU0io7qfCr9BMwzcrdOTmHb3tCzQPU/NhDjhAD2B5AQc K89Yg5YghSoMWuEabtcQReLdacShb852tMOgc0bjg+ScKIK2IbRAhjAcPZ9pkt4f7GQL 0nK74E97By3NqkbwAQUO3+WIiI2aypAbmibOTC1m4/bgSkdBV5f9bhqO23hwxsuPMY6C GpHtoqLfLIBC6OWZ78IEJ/k3Eppx3OPoi4kgV1HCrBVInVdY751GeF/E9WyFJaWxINI/ BL3AT1agT95LsJo5zazWTX78U5y69pyjBTKp/kF/FRRscvV/P7V/UQsCT3Z5eyOygRzL O3Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:to:from; bh=KZIUiuhlc9UVcdV/SRoskPnqmzHAtsGRyW/vaP+aDhc=; b=xtRzPiVpxZjvl4DYQRObfONE0BK87vZvvdxzqdzkWjsop7OTT81FkpXEVjI8bAqfM7 2o8faXagnm6tI1mgTQepsfda5F5VH43PY0TO9xNHzgGXbG/tO3KXADPRkuqNn5IfdbWj 61X+VvdqXceQFsXyUbb//kaOM+EA1DbxMGIKqZ40+jn3sisF5HWVYYYAD9Ra2g361U9o MwTG1m3uXllPXyT4dHSgmLIjxyiyxYM8RevmWxsVrPXYxZbAaKSn6fm0MSAyzhilWkTW D9FZ97B76F+aLIfytAasXylBslb2QuRIoMZlT7I1ff5lqvPwQMtyvcwp61CjnUcc1PG2 OVYQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ruc.edu.cn Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y18-20020a17090322d200b00163efcfadedsi29573031plg.255.2022.06.07.08.53.12; Tue, 07 Jun 2022 08:53:25 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ruc.edu.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242634AbiFGM2r (ORCPT + 99 others); Tue, 7 Jun 2022 08:28:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229549AbiFGM2r (ORCPT ); Tue, 7 Jun 2022 08:28:47 -0400 Received: from smtp.ruc.edu.cn (m177126.mail.qiye.163.com [123.58.177.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BD7B5F8D0; Tue, 7 Jun 2022 05:28:43 -0700 (PDT) Received: from localhost.localdomain (unknown [202.112.113.212]) by smtp.ruc.edu.cn (Hmail) with ESMTPSA id D86058008D; Tue, 7 Jun 2022 20:28:40 +0800 (CST) From: Xiaohui Zhang To: Xiaohui Zhang , Shay Agroskin , Arthur Kiyanovski , David Arinzon , Noam Dagan , Saeed Bishara , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Sameeh Jubran , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/1] net: ena_netdev: fix resource leak Date: Tue, 7 Jun 2022 20:28:31 +0800 Message-Id: <20220607122831.32738-1-xiaohuizhang@ruc.edu.cn> X-Mailer: git-send-email 2.17.1 X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgPGg8OCBgUHx5ZQUlOS1dZCBgUCR5ZQVlLVUtZV1 kWDxoPAgseWUFZKDYvK1lXWShZQUhPN1dZLVlBSVdZDwkaFQgSH1lBWUMYTE5WSUtIQ01ITxkaGB kaVRMBExYaEhckFA4PWVdZFhoPEhUdFFlBWU9LSFVKSktITUpVS1kG X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6P006Cio6MT0*Fxc8AU8iSzUe S1EwCkxVSlVKTU5PTUtPQklKTElNVTMWGhIXVQMSGhQTDhIBExoVHDsJDhhVHh8OVRgVRVlXWRIL WUFZSUtJVUpKSVVKSkhVSUpJWVdZCAFZQUlOSUo3Bg++ X-HM-Tid: 0a813e2379f42c20kusnd86058008d X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, 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 Similar to the handling of u132_hcd_init in commit f276e002793c ("usb: u132-hcd: fix resource leak"), we thought a patch might be needed here as well. If platform_driver_register fails, cleanup the allocated resource gracefully. Signed-off-by: Xiaohui Zhang --- drivers/net/ethernet/amazon/ena/ena_netdev.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c index 6a356a6cee15..c0624ee8d867 100644 --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c @@ -4545,13 +4545,17 @@ static struct pci_driver ena_pci_driver = { static int __init ena_init(void) { + int retval; ena_wq = create_singlethread_workqueue(DRV_MODULE_NAME); if (!ena_wq) { pr_err("Failed to create workqueue\n"); return -ENOMEM; } + retval = pci_register_driver(&ena_pci_driver); + if (retval) + destroy_workqueue(ena_wq); - return pci_register_driver(&ena_pci_driver); + return retval; } static void __exit ena_cleanup(void) -- 2.17.1