The NLA_PUT macro will automatically goto nla_put_failure if
the underlying nla_put fails. This will in turn leak our malloced
memory in both the scan and wowlan commands.
Fix that by not using the macro in the cases where we have
allocated heap mem.
Signed-off-by: Ola Olsson <ola.olsson@sonymobile.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
memcpy(&tmpies[ies_len], meshid, meshid_len);
free(meshid);
}
- NLA_PUT(msg, NL80211_ATTR_IE, ies_len + meshid_len, tmpies);
+ if (nla_put(msg, NL80211_ATTR_IE, ies_len + meshid_len, tmpies) < 0) {
+ free(tmpies);
+ goto nla_put_failure;
+ }
free(tmpies);
}
tok->offset = atoi(offs);
memcpy(tok->token_stream, stream, stream_len);
- NLA_PUT(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD_TOKEN,
- sizeof(*tok) + stream_len, tok);
+ if (nla_put(msg, NL80211_WOWLAN_TCP_DATA_PAYLOAD_TOKEN,
+ sizeof(*tok) + stream_len, tok) < 0) {
+ free(stream);
+ free(tok);
+ goto nla_put_failure;
+ }
free(stream);
free(tok);
} else {