From patchwork Fri Jul 26 18:50:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Linus_L=C3=BCssing?= X-Patchwork-Id: 3212 Return-Path: Received: from mout.web.de (mout.web.de [212.227.15.3]) by open-mesh.org (Postfix) with ESMTP id 438976006D9 for ; Fri, 26 Jul 2013 20:51:10 +0200 (CEST) Received: from localhost ([46.246.33.183]) by smtp.web.de (mrweb003) with ESMTPSA (Nemesis) id 0M5OaF-1UAR7t3ng7-00zWhO for ; Fri, 26 Jul 2013 20:51:09 +0200 From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: b.a.t.m.a.n@lists.open-mesh.org Date: Fri, 26 Jul 2013 20:50:45 +0200 Message-Id: <1374864646-19268-1-git-send-email-linus.luessing@web.de> X-Mailer: git-send-email 1.8.3.2 MIME-Version: 1.0 X-Provags-ID: V03:K0:v1vEqJEMdOVHggiUlu9XFtUvpFGyWBHvwEAdFyNj04ug9n6Pjax kZVjpnwb/rwxwl0OEDvtEXHNcqArQqFh1Rtotd7kbPYVT8PyC/5xevOWnKQdgZjcV7DBzrh E2+sopYR1OktOa+jubF5lvt5DKYr6Wn9JopHCPwRoORMn17lqB5Uh4Pqs0uN1TRp2/Me0eY AWbditxuYc/sQciAbgbjw== Subject: [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: check return type of unicast packet preparations X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.15 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: Fri, 26 Jul 2013 18:51:10 -0000 batadv_send_skb_prepare_unicast(_4addr) might reallocate the skb's data. And if it tries to do so then this can potentially fail. We shouldn't continue working on this skb in such a case. Signed-off-by: Linus Lüssing --- send.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/send.c b/send.c index d2cc507..9c9cab6 100644 --- a/send.c +++ b/send.c @@ -266,11 +266,14 @@ static int batadv_send_skb_unicast(struct batadv_priv *bat_priv, switch (packet_type) { case BATADV_UNICAST: - batadv_send_skb_prepare_unicast(skb, orig_node); + if (!batadv_send_skb_prepare_unicast(skb, orig_node)) + goto out; break; case BATADV_UNICAST_4ADDR: - batadv_send_skb_prepare_unicast_4addr(bat_priv, skb, orig_node, - packet_subtype); + if (!batadv_send_skb_prepare_unicast_4addr(bat_priv, skb, + orig_node, + packet_subtype)) + goto out; break; default: /* this function supports UNICAST and UNICAST_4ADDR only. It