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>
  * @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 {
        s32 signal;
        enum cfg80211_signal_type signal_type;
 
+       void (*free_priv)(struct cfg80211_bss *bss);
        u8 priv[0] __attribute__((__aligned__(sizeof(void *))));
 };
 
 
        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);
 }
 
 
        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);
 }