]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
iw: Change socket configuration to avoid buffer allocation error
authorTribush, Gil <gil.tribush@intel.com>
Wed, 18 May 2016 11:22:10 +0000 (11:22 +0000)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 31 May 2016 09:38:14 +0000 (11:38 +0200)
Move nl_socket_set_buffer_size() to be called after genl_connect(),
otherwise nl_socket_set_buffer_size() always returns an NLE_BAD_SOCK
error because sk->s_fd is equal to -1 at that stage.

Signed-off-by: Gil Treibush <gil.tribush@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
iw.c

diff --git a/iw.c b/iw.c
index 2aabddb3c12005e67cb739a2c45a58b72630124e..64f9f0f84a1b87bf2a16850362d3ddfe33ad9e94 100644 (file)
--- a/iw.c
+++ b/iw.c
@@ -54,14 +54,14 @@ static int nl80211_init(struct nl80211_state *state)
                return -ENOMEM;
        }
 
-       nl_socket_set_buffer_size(state->nl_sock, 8192, 8192);
-
        if (genl_connect(state->nl_sock)) {
                fprintf(stderr, "Failed to connect to generic netlink.\n");
                err = -ENOLINK;
                goto out_handle_destroy;
        }
 
+       nl_socket_set_buffer_size(state->nl_sock, 8192, 8192);
+
        state->nl80211_id = genl_ctrl_resolve(state->nl_sock, "nl80211");
        if (state->nl80211_id < 0) {
                fprintf(stderr, "nl80211 not found.\n");