From patchwork Mon Aug 19 16:59:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 268265 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 595162C011F for ; Tue, 20 Aug 2013 03:02:43 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751030Ab3HSRCl (ORCPT ); Mon, 19 Aug 2013 13:02:41 -0400 Received: from diserzione.investici.org ([82.221.99.153]:50502 "EHLO diserzione.investici.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750840Ab3HSRCj (ORCPT ); Mon, 19 Aug 2013 13:02:39 -0400 Received: from [82.221.99.153] (diserzione [82.221.99.153]) (Authenticated sender: ordex@autistici.org) by localhost (Postfix) with ESMTPSA id E5639180DB3; Mon, 19 Aug 2013 17:02:36 +0000 (UTC) X-DKIM: OpenDKIM Filter v2.6.8 diserzione.investici.org E5639180DB3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1376931758; bh=pikquQ70qVQGG17ziuv7apavtvAskoiXm+VHw2n4Xes=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=MpSDd15J5BqUL1uI5SyZ0ZETCYMXGXt0aqWQ9I/gNnaAO1CHpCJUCVSmy68+bud0N wqkPpG3OYF+P0zWj/m0kISu0vepYMAq6EFplWm5fTMuEHpEY0vSRM+72/CKEwc+9rG WG82UP5V/vgFwkSv9Ax8NB1QOucGyoQDiDRMt9n0= From: Antonio Quartulli To: davem@davemloft.net Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org, =?UTF-8?q?Linus=20L=C3=BCssing?= , Marek Lindner , Antonio Quartulli Subject: [PATCH] batman-adv: check return type of unicast packet preparations Date: Mon, 19 Aug 2013 18:59:55 +0200 Message-Id: <1376931595-2070-2-git-send-email-ordex@autistici.org> X-Mailer: git-send-email 1.8.1.5 In-Reply-To: <1376931595-2070-1-git-send-email-ordex@autistici.org> References: <1376931595-2070-1-git-send-email-ordex@autistici.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Linus Lüssing batadv_unicast(_4addr)_prepare_skb 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 Signed-off-by: Marek Lindner Acked-by: Antonio Quartulli Signed-off-by: Antonio Quartulli --- net/batman-adv/unicast.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c index 688a041..857e1b8 100644 --- a/net/batman-adv/unicast.c +++ b/net/batman-adv/unicast.c @@ -432,12 +432,16 @@ find_router: switch (packet_type) { case BATADV_UNICAST: - batadv_unicast_prepare_skb(skb, orig_node); + if (!batadv_unicast_prepare_skb(skb, orig_node)) + goto out; + header_len = sizeof(struct batadv_unicast_packet); break; case BATADV_UNICAST_4ADDR: - batadv_unicast_4addr_prepare_skb(bat_priv, skb, orig_node, - packet_subtype); + if (!batadv_unicast_4addr_prepare_skb(bat_priv, skb, orig_node, + packet_subtype)) + goto out; + header_len = sizeof(struct batadv_unicast_4addr_packet); break; default: