[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190504030813.17684-1-baijiaju1990@gmail.com>
Date: Sat, 4 May 2019 11:08:13 +0800
From: Jia-Ju Bai <baijiaju1990@...il.com>
To: davem@...emloft.net
Cc: netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
Jia-Ju Bai <baijiaju1990@...il.com>
Subject: [PATCH] net: via-rhine: net: Fix a resource leak in rhine_init()
When platform_driver_register() fails, pci_unregister_driver() is not
called to release the resource allocated by pci_register_driver().
To fix this bug, error handling code for platform_driver_register() and
pci_register_driver() is separately implemented.
This bug is found by a runtime fuzzing tool named FIZZER written by us.
Signed-off-by: Jia-Ju Bai <baijiaju1990@...il.com>
---
drivers/net/ethernet/via/via-rhine.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c
index 33949248c829..eb74e5a03aac 100644
--- a/drivers/net/ethernet/via/via-rhine.c
+++ b/drivers/net/ethernet/via/via-rhine.c
@@ -2633,10 +2633,15 @@ static int __init rhine_init(void)
pr_info("avoid_D3 set\n");
ret_pci = pci_register_driver(&rhine_driver_pci);
- ret_platform = platform_driver_register(&rhine_driver_platform);
- if ((ret_pci < 0) && (ret_platform < 0))
+ if (ret_pci)
return ret_pci;
+ ret_platform = platform_driver_register(&rhine_driver_platform);
+ if (ret_platform) {
+ pci_unregister_driver(&rhine_driver_pci);
+ return ret_platform;
+ }
+
return 0;
}
--
2.17.0
Powered by blists - more mailing lists