Search Linux Wireless

[PATCH V2] iw: Avoid possible memory leak for cb

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



cb got memory from nl_cb_alloc() but not doing free
during error case and use same lable to go out from function.

Signed-off-by: Amit Khatri <amit.khatri@xxxxxxxxxxx>
Signed-off-by: Rahul Jain <rahul.jain@xxxxxxxxxxx>
---
 iw.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/iw.c b/iw.c
index ec56736..1385441 100644
--- a/iw.c
+++ b/iw.c
@@ -476,13 +476,13 @@ static int __handle_cmd(struct nl80211_state *state, enum id_input idby,
 
 	err = cmd->handler(state, msg, argc, argv, idby);
 	if (err)
-		goto out;
+		goto out_free_msg;
 
 	nl_socket_set_cb(state->nl_sock, s_cb);
 
 	err = nl_send_auto_complete(state->nl_sock, msg);
 	if (err < 0)
-		goto out;
+		goto out_free_msg;
 
 	err = 1;
 
@@ -493,9 +493,11 @@ static int __handle_cmd(struct nl80211_state *state, enum id_input idby,
 
 	while (err > 0)
 		nl_recvmsgs(state->nl_sock, cb);
- out:
-	nl_cb_put(cb);
  out_free_msg:
+	if(!cb)
+		nl_cb_put(cb);
+	if(!s_cb)
+		nl_cb_put(s_cb);
 	nlmsg_free(msg);
 	return err;
  nla_put_failure:
-- 
1.9.1��.n��������+%������w��{.n�����{���zW����ܨ}���Ơz�j:+v�����w����ޙ��&�)ߡ�a����z�ޗ���ݢj��w�f




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux