From patchwork Thu Jan 7 19:43:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfgang Grandegger X-Patchwork-Id: 42468 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 3DF451011D1 for ; Fri, 8 Jan 2010 06:43:53 +1100 (EST) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by ozlabs.org (Postfix) with ESMTP id 42C7E1007D2; Fri, 8 Jan 2010 06:43:12 +1100 (EST) Received: from mail01.m-online.net (mail.m-online.net [192.168.3.149]) by mail-out.m-online.net (Postfix) with ESMTP id 353121C1541D; Thu, 7 Jan 2010 20:43:09 +0100 (CET) X-Auth-Info: cuSjuT+5GDI8zz25h0Laa5fL0he3hyMiSDUaXTwG49I= Received: from mail.denx.de (host-82-135-33-74.customer.m-online.net [82.135.33.74]) by smtp-auth.mnet-online.de (Postfix) with ESMTP id 1471E9018F; Thu, 7 Jan 2010 20:43:09 +0100 (CET) Received: from pollux.denx.de (pollux [192.168.1.1]) by mail.denx.de (Postfix) with ESMTP id CC5864230B49; Thu, 7 Jan 2010 20:43:08 +0100 (CET) Received: by pollux.denx.de (Postfix, from userid 504) id 9E1351012361E; Thu, 7 Jan 2010 20:43:08 +0100 (CET) From: Wolfgang Grandegger To: Netdev@vger.kernel.org Subject: [PATCH net-next v4 1/3] can: mscan: fix improper return if dlc < 8 in start_xmit function Date: Thu, 7 Jan 2010 20:43:06 +0100 Message-Id: <1262893388-16218-2-git-send-email-wg@grandegger.com> X-Mailer: git-send-email 1.6.2.5 In-Reply-To: <1262893388-16218-1-git-send-email-wg@grandegger.com> References: <1262893388-16218-1-git-send-email-wg@grandegger.com> Cc: Socketcan-core@lists.berlios.de, Devicetree-discuss@lists.ozlabs.org, Linuxppc-dev@lists.ozlabs.org, Wolfgang Grandegger X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org From: Wolfgang Grandegger The start_xmit function of the MSCAN Driver did return improperly if the CAN dlc check failed (skb not freed and invalid return code). This patch adds a proper check of the frame lenght and data size and returns now correctly. The invalid skb packets are dropped silently as suggested by David Miller in the thread "[RFC] ndo_validate_skb: Let the netdev check a valid skb content" on the netdev mailing list. Furthermore, a typo has been fixed. Signed-off-by: Wolfgang Grandegger Reviewed-by: Wolfram Sang --- drivers/net/can/mscan/mscan.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/can/mscan/mscan.c b/drivers/net/can/mscan/mscan.c index 07346f8..0dcbe8c 100644 --- a/drivers/net/can/mscan/mscan.c +++ b/drivers/net/can/mscan/mscan.c @@ -4,7 +4,7 @@ * Copyright (C) 2005-2006 Andrey Volkov , * Varma Electronics Oy * Copyright (C) 2008-2009 Wolfgang Grandegger - * Copytight (C) 2008-2009 Pengutronix + * Copyright (C) 2008-2009 Pengutronix * * This program is free software; you can redistribute it and/or modify * it under the terms of the version 2 of the GNU General Public License @@ -177,8 +177,11 @@ static netdev_tx_t mscan_start_xmit(struct sk_buff *skb, struct net_device *dev) int i, rtr, buf_id; u32 can_id; - if (frame->can_dlc > 8) - return -EINVAL; + if (skb->len != sizeof(*frame) || frame->can_dlc > 8) { + kfree_skb(skb); + dev->stats.tx_dropped++; + return NETDEV_TX_OK; + } out_8(®s->cantier, 0);