aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/can
diff options
context:
space:
mode:
authorWolfgang Grandegger <wg@denx.de>2010-01-07 04:43:06 -0500
committerDavid S. Miller <davem@davemloft.net>2010-01-08 04:02:17 -0500
commit2d4b6faf7d1818e9a52ae9f068ab4ffd9c3be923 (patch)
treeea83652ec221c38122ac4cc524e365db81b9d4c7 /drivers/net/can
parent5856b606e69d3e4dc2d718b475e216eb30ee2006 (diff)
can: mscan: fix improper return if dlc < 8 in start_xmit function
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 <wg@denx.de> Reviewed-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/can')
-rw-r--r--drivers/net/can/mscan/mscan.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/net/can/mscan/mscan.c b/drivers/net/can/mscan/mscan.c
index 07346f880ca6..0dcbe8cfab64 100644
--- a/drivers/net/can/mscan/mscan.c
+++ b/drivers/net/can/mscan/mscan.c
@@ -4,7 +4,7 @@
4 * Copyright (C) 2005-2006 Andrey Volkov <avolkov@varma-el.com>, 4 * Copyright (C) 2005-2006 Andrey Volkov <avolkov@varma-el.com>,
5 * Varma Electronics Oy 5 * Varma Electronics Oy
6 * Copyright (C) 2008-2009 Wolfgang Grandegger <wg@grandegger.com> 6 * Copyright (C) 2008-2009 Wolfgang Grandegger <wg@grandegger.com>
7 * Copytight (C) 2008-2009 Pengutronix <kernel@pengutronix.de> 7 * Copyright (C) 2008-2009 Pengutronix <kernel@pengutronix.de>
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the version 2 of the GNU General Public License 10 * 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)
177 int i, rtr, buf_id; 177 int i, rtr, buf_id;
178 u32 can_id; 178 u32 can_id;
179 179
180 if (frame->can_dlc > 8) 180 if (skb->len != sizeof(*frame) || frame->can_dlc > 8) {
181 return -EINVAL; 181 kfree_skb(skb);
182 dev->stats.tx_dropped++;
183 return NETDEV_TX_OK;
184 }
182 185
183 out_8(&regs->cantier, 0); 186 out_8(&regs->cantier, 0);
184 187