cfg80211: free_priv for BSS info
authorJohannes Berg <johannes@sipsolutions.net>
Tue, 10 Feb 2009 20:25:57 +0000 (21:25 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 13 Feb 2009 18:45:53 +0000 (13:45 -0500)
When cfg80211 users have their own allocated data in the per-BSS
private data, they will need to free this when the BSS struct is
destroyed. Add a free_priv method and fix one place where the BSS
was kfree'd rather than released properly.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
include/net/cfg80211.h
net/wireless/core.c
net/wireless/scan.c

index 09a0b268e5cfe5718252202d2a7e7ef7436b4f71..b514abcc2b938d7d364c6a13ad25f9a8a73d30e7 100644 (file)
@@ -567,6 +567,7 @@ enum cfg80211_signal_type {
  * @len_information_elements: total length of the information elements
  * @signal: signal strength value
  * @signal_type: signal type
+ * @free_priv: function pointer to free private data
  * @priv: private area for driver use, has at least wiphy->bss_priv_size bytes
  */
 struct cfg80211_bss {
@@ -582,6 +583,7 @@ struct cfg80211_bss {
        s32 signal;
        enum cfg80211_signal_type signal_type;
 
+       void (*free_priv)(struct cfg80211_bss *bss);
        u8 priv[0] __attribute__((__aligned__(sizeof(void *))));
 };
 
index 3cccd1390cea6345af26cc985120236fe797a6f7..0668b2bfc1dafb4c880b565a1a12ec8e30e9e329 100644 (file)
@@ -376,7 +376,7 @@ void cfg80211_dev_free(struct cfg80211_registered_device *drv)
        mutex_destroy(&drv->mtx);
        mutex_destroy(&drv->devlist_mtx);
        list_for_each_entry_safe(scan, tmp, &drv->bss_list, list)
-               kfree(scan);
+               cfg80211_put_bss(&scan->pub);
        kfree(drv);
 }
 
index 009d12810c55e7dd07f141efb9c645104126f713..ec148f68a62b836be041c62608a702066cf22a19 100644 (file)
@@ -56,6 +56,8 @@ static void bss_release(struct kref *ref)
        struct cfg80211_internal_bss *bss;
 
        bss = container_of(ref, struct cfg80211_internal_bss, ref);
+       if (bss->pub.free_priv)
+               bss->pub.free_priv(&bss->pub);
        kfree(bss);
 }