From 57f22bcbdaf753f02edc74287585ed628d282fc7 Mon Sep 17 00:00:00 2001 From: scottr Date: Thu, 26 Jun 2008 08:23:41 +0000 Subject: [PATCH] Register sysctl before doing pci registration. This fixes a bug when renaming multiple wireless cards on slow devices. The pci registration causes udev to rename the device but the sysctl is not registered yet so the device renames but the corresponding sysctl entries are not renamed. git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@3746 0192ed92-7a03-0410-a25b-9323aeb14dbd --- ath/if_ath.c | 6 ++++++ ath/if_ath_pci.c | 8 +++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ath/if_ath.c b/ath/if_ath.c index 819f48a..d863cc1 100644 --- a/ath/if_ath.c +++ b/ath/if_ath.c @@ -11024,6 +11024,10 @@ ath_dynamic_sysctl_register(struct ath_softc *sc) unsigned int i, space; char *dev_name = NULL; + /* Prevent multiple registrations */ + if (sc->sc_sysctls) + return; + space = 5 * sizeof(struct ctl_table) + sizeof(ath_sysctl_template); sc->sc_sysctls = kzalloc(space, GFP_KERNEL); if (sc->sc_sysctls == NULL) { @@ -11041,6 +11045,8 @@ ath_dynamic_sysctl_register(struct ath_softc *sc) dev_name = kmalloc((strlen(DEV_NAME(sc->sc_dev)) + 1) * sizeof(char), GFP_KERNEL); if (dev_name == NULL) { EPRINTF(sc, "Insufficient memory for device name storage!\n"); + kfree(sc->sc_sysctls); + sc->sc_sysctls = NULL; return; } strncpy(dev_name, DEV_NAME(sc->sc_dev), strlen(DEV_NAME(sc->sc_dev)) + 1); diff --git a/ath/if_ath_pci.c b/ath/if_ath_pci.c index 7132607..f9ccd1e 100644 --- a/ath/if_ath_pci.c +++ b/ath/if_ath_pci.c @@ -380,10 +380,12 @@ MODULE_LICENSE("Dual BSD/GPL"); static int __init init_ath_pci(void) { - int status = pci_register_driver(&ath_pci_driver); - if (status) - return (status); + int status; ath_sysctl_register(); + if ((status = pci_register_driver(&ath_pci_driver))) { + ath_sysctl_unregister(); + return (status); + } return (0); } module_init(init_ath_pci); -- 2.35.1