device: Build MDE in a static buffer

Fix a leak of the MDE buffer.  It is now only needed for the single call
to handshake_state_set_mde which copies the bytes anyway so use a buffer
on stack.
This commit is contained in:
Andrew Zaborowski 2017-02-10 03:23:16 +01:00 committed by Denis Kenzior
parent 7006d18550
commit 1307a815a6
1 changed files with 2 additions and 6 deletions

View File

@ -1105,7 +1105,6 @@ void device_connect_network(struct device *device, struct network *network,
struct l_dbus *dbus = dbus_get_bus();
struct handshake_state *hs;
bool add_mde = false;
uint8_t *mde;
hs = handshake_state_new(netdev_get_ifindex(device->netdev));
@ -1205,7 +1204,7 @@ void device_connect_network(struct device *device, struct network *network,
add_mde = bss->mde_present;
if (add_mde) {
mde = l_malloc(5);
uint8_t mde[5];
/* The MDE advertised by the BSS must be passed verbatim */
mde[0] = IE_TYPE_MOBILITY_DOMAIN;
@ -1213,8 +1212,7 @@ void device_connect_network(struct device *device, struct network *network,
memcpy(mde + 2, bss->mde, 3);
handshake_state_set_mde(hs, mde);
} else
mde = NULL;
}
device->connect_pending = l_dbus_message_ref(message);
@ -1222,8 +1220,6 @@ void device_connect_network(struct device *device, struct network *network,
device_connect_cb, device) < 0) {
handshake_state_free(hs);
l_free(mde);
dbus_pending_reply(&device->connect_pending,
dbus_error_failed(device->connect_pending));
return;