diff mbox

iw: Change socket configuration to avoid buffer allocation error

Message ID 9500D1AF62AEC945997ED710048926644CF4360C@HASMSX106.ger.corp.intel.com (mailing list archive)
State Accepted
Delegated to: Johannes Berg
Headers show

Commit Message

Tribush, Gil May 18, 2016, 11:22 a.m. UTC
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>
---
iw.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)


--
1.9.1
---------------------------------------------------------------------
A member of the Intel Corporation group of companies

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Johannes Berg May 31, 2016, 9:37 a.m. UTC | #1
On Wed, 2016-05-18 at 11:22 +0000, Tribush, Gil wrote:
> 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.
> 

Applied.

johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/iw.c b/iw.c
index 0f511d9..e3742cd 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");