From: Tribush, Gil Date: Wed, 18 May 2016 11:22:10 +0000 (+0000) Subject: iw: Change socket configuration to avoid buffer allocation error X-Git-Tag: v4.7~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7687d5963b5dcc1bb68a1ed8fe99d0a52b65d8b1;p=thirdparty%2Fiw.git iw: Change socket configuration to avoid buffer allocation error 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 Signed-off-by: Johannes Berg --- diff --git a/iw.c b/iw.c index 2aabddb..64f9f0f 100644 --- 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");