]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Do not double free cfg struct if netlink_init() fails
authorPontus Fuchs <pontus.fuchs@gmail.com>
Sat, 24 Nov 2012 14:47:20 +0000 (16:47 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 24 Nov 2012 14:47:20 +0000 (16:47 +0200)
If netlink_init() fails on socket create or bind the cfg struct
provided as parameter is freed by netlink_init(). Callers of
netlink_init() also free this struct on their error paths leading
to double free.

Signed-hostap: Pontus Fuchs <pontus.fuchs@gmail.com>

src/drivers/netlink.c

index dd662f371dac75fb182111cd6ce80541d748d6e2..6c60550fd613dc9566616e8fd3174651aa69d0f6 100644 (file)
@@ -97,8 +97,6 @@ struct netlink_data * netlink_init(struct netlink_config *cfg)
        if (netlink == NULL)
                return NULL;
 
-       netlink->cfg = cfg;
-
        netlink->sock = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
        if (netlink->sock < 0) {
                wpa_printf(MSG_ERROR, "netlink: Failed to open netlink "
@@ -121,6 +119,8 @@ struct netlink_data * netlink_init(struct netlink_config *cfg)
        eloop_register_read_sock(netlink->sock, netlink_receive, netlink,
                                 NULL);
 
+       netlink->cfg = cfg;
+
        return netlink;
 }