From patchwork Thu Jun 16 10:37:07 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Lindner X-Patchwork-Id: 1143 Return-Path: Received: from nm16.bullet.mail.ukl.yahoo.com (nm16.bullet.mail.ukl.yahoo.com [217.146.183.190]) by open-mesh.org (Postfix) with SMTP id 13E72154173 for ; Thu, 16 Jun 2011 12:37:16 +0200 (CEST) Authentication-Results: open-mesh.org; dkim=pass (1024-bit key) header.i=@yahoo.de; dkim-adsp=none Received: from [217.146.183.211] by nm16.bullet.mail.ukl.yahoo.com with NNFMP; 16 Jun 2011 10:37:15 -0000 Received: from [77.238.184.69] by tm4.bullet.mail.ukl.yahoo.com with NNFMP; 16 Jun 2011 10:37:15 -0000 Received: from [127.0.0.1] by smtp138.mail.ukl.yahoo.com with NNFMP; 16 Jun 2011 10:37:15 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s1024; t=1308220635; bh=9ttqreebCxOeys1z6H8wPCzPXKgNkf+QGSE43rCJouM=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer; b=o9wKxXe/dW2e9GCWTSOKwlON187poGccPYP54qsknGnTjGiUpzRAUgeq/MPLRxpkXkR0ILmJEyhrAqmug8GGsbxOHVJbSJi1XQMPjv1SVsOxRI9LVZT+i0RzMFedR3b/0fKw7R/MO+QoOOHpPm6oC2bXwbSkWc/R0o+w4uLSxyI= X-Yahoo-Newman-Id: 861028.87037.bm@smtp138.mail.ukl.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: z_QS0HUVM1n9XiFaLDFNUYZbxPTOP5rDKMvfhWMX66b7z7w Ku7rGtO3LZVBXzG9b9bKVvK..zyIbSmcKmzPTB68Cu5O8SRQphbyEk4OYx1t N9lOXqCAIapf4QZ1v3nm2r.h_9k0T9suE6ffEfKNrEMaPCNPg0OSP9Mtyf0S cPjn2_P0GQruc863IVsRZdE8f5YUK0C0SOBcwEkK8T5DTI.oP1VI1qqg1Ky8 1UGFWy9RTtiYM7817rSKJtzuj8TOVo7qvVwKEFZIjEtiHi0Tcl38PH9YFzD. Sms4CxSmSQjjjRIdTkpSXDZnEG08G1ge0WzDqmS1Rfdn0KQYrGIQv8zdFw_S 5cmGUpg-- X-Yahoo-SMTP: tW.h3tiswBBMXO2coYcbPigGD5Lt6zY_.Zc- Received: from localhost (lindner_marek@90.61.252.3 with plain) by smtp138.mail.ukl.yahoo.com with SMTP; 16 Jun 2011 10:37:14 +0000 GMT From: Marek Lindner To: b.a.t.m.a.n@lists.open-mesh.org Date: Thu, 16 Jun 2011 12:37:07 +0200 Message-Id: <1308220627-27164-1-git-send-email-lindner_marek@yahoo.de> X-Mailer: git-send-email 1.7.5.3 Cc: Marek Lindner Subject: [B.A.T.M.A.N.] [PATCH] batman-adv: fix cleanup in send_tt_request() X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Jun 2011 10:37:16 -0000 The ret variable was never set to any value other than 0, therefore the skb and tt_req_node would not be freed in case of an error. Furthermore, the code assumed tt_req_node being always a valid pointer by dereferencing it in the cleanup part. Signed-off-by: Marek Lindner Acked-by: Antonio Quartulli --- translation-table.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/translation-table.c b/translation-table.c index 373ee81..5f1fcd5 100644 --- a/translation-table.c +++ b/translation-table.c @@ -1012,12 +1012,12 @@ out: int send_tt_request(struct bat_priv *bat_priv, struct orig_node *dst_orig_node, uint8_t ttvn, uint16_t tt_crc, bool full_table) { - struct sk_buff *skb; + struct sk_buff *skb = NULL; struct tt_query_packet *tt_request; struct neigh_node *neigh_node = NULL; struct hard_iface *primary_if; - struct tt_req_node *tt_req_node; - int ret = 0; + struct tt_req_node *tt_req_node = NULL; + int ret = 1; primary_if = primary_if_get_selected(bat_priv); if (!primary_if) @@ -1066,8 +1066,9 @@ out: neigh_node_free_ref(neigh_node); if (primary_if) hardif_free_ref(primary_if); - if (ret) { + if (ret) kfree_skb(skb); + if (ret && tt_req_node) { spin_lock_bh(&bat_priv->tt_req_list_lock); list_del(&tt_req_node->list); spin_unlock_bh(&bat_priv->tt_req_list_lock);