lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <pj41zly1y8pabi.fsf@u570694869fb251.ant.amazon.com>
Date:   Tue, 7 Jun 2022 21:57:43 +0300
From:   Shay Agroskin <shayagr@...zon.com>
To:     Xiaohui Zhang <xiaohuizhang@....edu.cn>
CC:     Arthur Kiyanovski <akiyano@...zon.com>,
        David Arinzon <darinzon@...zon.com>,
        Noam Dagan <ndagan@...zon.com>,
        Saeed Bishara <saeedb@...zon.com>,
        "David S . Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>,
        Sameeh Jubran <sameehj@...zon.com>, <netdev@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/1] net: ena_netdev: fix resource leak


Xiaohui Zhang <xiaohuizhang@....edu.cn> writes:

> 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 <xiaohuizhang@....edu.cn>
> ---
>  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)

Hi,
thanks a lot for this patch. I made a few small changes in it to 
make it more consistent with the rest of driver's code
(sorry don't really know how to insert an inline diff)

thanks,
Shay

---
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c 
b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index 6a356a6cee15..be8d3c26c9bb 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -4545,13 +4545,19 @@ static struct pci_driver ena_pci_driver = 
{
 
 static int __init ena_init(void)
 {
+	int rc;
+
 	ena_wq = create_singlethread_workqueue(DRV_MODULE_NAME);
 	if (!ena_wq) {
 		pr_err("Failed to create workqueue\n");
 		return -ENOMEM;
 	}
 
-	return pci_register_driver(&ena_pci_driver);
+	rc = pci_register_driver(&ena_pci_driver);
+	if (rc)
+		destroy_workqueue(ena_wq);
+
+	return rc;
 }
 
 static void __exit ena_cleanup(void)


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ