*/
 int cfg80211_sinfo_alloc_tid_stats(struct station_info *sinfo, gfp_t gfp);
 
+/**
+ * cfg80211_sinfo_release_content - release contents of station info
+ * @sinfo: the station information
+ *
+ * Releases any potentially allocated sub-information of the station
+ * information, but not the struct itself (since it's typically on
+ * the stack.)
+ */
+static inline void cfg80211_sinfo_release_content(struct station_info *sinfo)
+{
+       kfree(sinfo->pertid);
+}
+
 /**
  * cfg80211_new_sta - notify userspace about station
  *
 
                }
 
                nla_nest_end(msg, tidsattr);
-               kfree(sinfo->pertid);
        }
 
        nla_nest_end(msg, sinfoattr);
                    sinfo->assoc_req_ies))
                goto nla_put_failure;
 
+       cfg80211_sinfo_release_content(sinfo);
        genlmsg_end(msg, hdr);
        return 0;
 
  nla_put_failure:
+       cfg80211_sinfo_release_content(sinfo);
        genlmsg_cancel(msg, hdr);
        return -EMSGSIZE;
 }
                return err;
 
        msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
-       if (!msg)
+       if (!msg) {
+               cfg80211_sinfo_release_content(sinfo);
                return -ENOMEM;
+       }
 
        if (nl80211_send_station(msg, NL80211_CMD_NEW_STATION,
                                 info->snd_portid, info->snd_seq, 0,
        trace_cfg80211_del_sta(dev, mac_addr);
 
        msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
-       if (!msg)
+       if (!msg) {
+               cfg80211_sinfo_release_content(sinfo);
                return;
+       }
 
        if (nl80211_send_station(msg, NL80211_CMD_DEL_STATION, 0, 0, 0,
                                 rdev, dev, mac_addr, sinfo) < 0) {