Allocate ic and vap dynamically
authorproski <proski@0192ed92-7a03-0410-a25b-9323aeb14dbd>
Wed, 27 Aug 2008 15:58:30 +0000 (15:58 +0000)
committerproski <proski@0192ed92-7a03-0410-a25b-9323aeb14dbd>
Wed, 27 Aug 2008 15:58:30 +0000 (15:58 +0000)
git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@3846 0192ed92-7a03-0410-a25b-9323aeb14dbd

regression/ccmp/test_ccmp.c
regression/tkip/test_tkip.c
regression/wep/test_wep.c

index 909bb2859e576e0e0bb9effe8d41663920ec76b4..512d321d6118640b6f6f3df3027c961b04d96efc 100644 (file)
@@ -713,28 +713,40 @@ MODULE_PARM_DESC(debug, "Enable IEEE80211_MSG_CRYPTO");
 static int __init
 init_crypto_ccmp_test(void)
 {
-       struct ieee80211com ic;
-       struct ieee80211vap vap;
+       struct ieee80211com *ic;
+       struct ieee80211vap *vap;
        int i, pass, total;
 
-       memset(&ic, 0, sizeof(ic));
-       memset(&vap, 0, sizeof(vap));
-       vap.iv_ic = &ic;
+       ic = kzalloc(sizeof(*ic), GFP_KERNEL);
+       if (!ic)
+               return -ENOMEM;
+
+       ieee80211_crypto_attach(ic);
+
+       vap = kzalloc(sizeof(*vap), GFP_KERNEL);
+       if (!vap) {
+               kfree(ic);
+               return -ENOMEM;
+       }
+
+       vap->iv_ic = ic;
        if (debug)
-               vap.iv_debug = IEEE80211_MSG_CRYPTO;
-       ieee80211_crypto_attach(&ic);
-       ieee80211_crypto_vattach(&vap);
+               vap->iv_debug = IEEE80211_MSG_CRYPTO;
+
+       ieee80211_crypto_vattach(vap);
 
        pass = 0;
        total = 0;
        for (i = 0; i < ARRAY_SIZE(ccmptests); i++)
                if (tests & (1 << i)) {
                        total++;
-                       pass += runtest(&vap, &ccmptests[i]);
+                       pass += runtest(vap, &ccmptests[i]);
                }
        printk("%u of %u 802.11i AES-CCMP test vectors passed\n", pass, total);
-       ieee80211_crypto_vdetach(&vap);
-       ieee80211_crypto_detach(&ic);
+       ieee80211_crypto_vdetach(vap);
+       ieee80211_crypto_detach(ic);
+       kfree(vap);
+       kfree(ic);
        return (pass == total ? 0 : -ENXIO);
 }
 module_init(init_crypto_ccmp_test);
index 86b953553b3aaff5d6c8f78dcf60837443099f31..6b20577fc1d7926d673004196ce8517e788ce958 100644 (file)
@@ -372,28 +372,40 @@ MODULE_PARM_DESC(debug, "Enable IEEE80211_MSG_CRYPTO");
 static int __init
 init_crypto_tkip_test(void)
 {
-       struct ieee80211com ic;
-       struct ieee80211vap vap;
+       struct ieee80211com *ic;
+       struct ieee80211vap *vap;
        int i, pass, total;
 
-       memset(&ic, 0, sizeof(ic));
-       memset(&vap, 0, sizeof(vap));
-       vap.iv_ic = &ic;
+       ic = kzalloc(sizeof(*ic), GFP_KERNEL);
+       if (!ic)
+               return -ENOMEM;
+
+       ieee80211_crypto_attach(ic);
+
+       vap = kzalloc(sizeof(*vap), GFP_KERNEL);
+       if (!vap) {
+               kfree(ic);
+               return -ENOMEM;
+       }
+
+       vap->iv_ic = ic;
        if (debug)
-               vap.iv_debug = IEEE80211_MSG_CRYPTO;
-       ieee80211_crypto_attach(&ic);
-       ieee80211_crypto_vattach(&vap);
+               vap->iv_debug = IEEE80211_MSG_CRYPTO;
+
+       ieee80211_crypto_vattach(vap);
 
        pass = 0;
        total = 0;
        for (i = 0; i < ARRAY_SIZE(tkiptests); i++)
                if (tests & (1 << i)) {
                        total++;
-                       pass += runtest(&vap, &tkiptests[i]);
+                       pass += runtest(vap, &tkiptests[i]);
                }
        printk("%u of %u 802.11i TKIP test vectors passed\n", pass, total);
-       ieee80211_crypto_vdetach(&vap);
-       ieee80211_crypto_detach(&ic);
+       ieee80211_crypto_vdetach(vap);
+       ieee80211_crypto_detach(ic);
+       kfree(vap);
+       kfree(ic);
        return (pass == total ? 0 : -ENXIO);
 }
 module_init(init_crypto_tkip_test);
index efc95ad2a3aaaa9125f1507fc087143ffa1bc925..62d1e1c3a144167f3a4859eb27349259a766b301 100644 (file)
@@ -317,27 +317,40 @@ MODULE_PARM_DESC(debug, "Enable IEEE80211_MSG_CRYPTO");
 static int __init
 init_crypto_wep_test(void)
 {
-       struct ieee80211com ic;
-       struct ieee80211vap vap;
+       struct ieee80211com *ic;
+       struct ieee80211vap *vap;
        int i, pass, total;
 
-       memset(&ic, 0, sizeof(ic));
-       memset(&vap, 0, sizeof(vap));
-       vap.iv_ic = &ic;
+       ic = kzalloc(sizeof(*ic), GFP_KERNEL);
+       if (!ic)
+               return -ENOMEM;
+
+       ieee80211_crypto_attach(ic);
+
+       vap = kzalloc(sizeof(*vap), GFP_KERNEL);
+       if (!vap) {
+               kfree(ic);
+               return -ENOMEM;
+       }
+
+       vap->iv_ic = ic;
        if (debug)
-               vap.iv_debug = IEEE80211_MSG_CRYPTO;
-       ieee80211_crypto_attach(&ic);
-       ieee80211_crypto_vattach(&vap);
+               vap->iv_debug = IEEE80211_MSG_CRYPTO;
+
+       ieee80211_crypto_vattach(vap);
+
        pass = 0;
        total = 0;
        for (i = 0; i < ARRAY_SIZE(weptests); i++)
                if (tests & (1 << i)) {
                        total++;
-                       pass += runtest(&vap, &weptests[i]);
+                       pass += runtest(vap, &weptests[i]);
                }
        printk("%u of %u 802.11i WEP test vectors passed\n", pass, total);
-       ieee80211_crypto_vdetach(&vap);
-       ieee80211_crypto_detach(&ic);
+       ieee80211_crypto_vdetach(vap);
+       ieee80211_crypto_detach(ic);
+       kfree(vap);
+       kfree(ic);
        return (pass == total ? 0 : -ENXIO);
 }
 module_init(init_crypto_wep_test);