Thread (1 message) 1 message, 1 author, 2010-01-02

Re: [PATCH net-next 1/3] can: mscan: fix improper return if dlc < 8 in start_xmit function

From: Wolfgang Grandegger <hidden>
Date: 2010-01-02 15:34:21
Also in: linux-devicetree, linuxppc-dev

Wolfram Sang wrote:
On Sat, Jan 02, 2010 at 09:17:52AM +0100, Wolfgang Grandegger wrote:
quoted
From: Wolfgang Grandegger <redacted>

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. Furthermore, a typo has been fixed.
A few little things, but in general:

Acked-by: Wolfram Sang <redacted>
quoted
Signed-off-by: Wolfgang Grandegger <redacted>
---
 drivers/net/can/mscan/mscan.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/net/can/mscan/mscan.c b/drivers/net/can/mscan/mscan.c
index 07346f8..abdf5e8 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 <avolkov-ppI4tVfbJvJWk0Htik3J/w@public.gmane.org>,
  *                         Varma Electronics Oy
  * Copyright (C) 2008-2009 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
- * Copytight (C) 2008-2009 Pengutronix <kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
+ * Copyright (C) 2008-2009 Pengutronix <kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  *
  * 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,13 @@ 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) {
+		dev_err(dev->dev.parent,
+			"Dropping non-conform paket: len %d, can_dlc %d\n",
s/paket/packet/
quoted
+			skb->len, frame->can_dlc);
Also, shouldn't it rather be %u (sk_buff->len is unsigned int)?
Will fix both issue.

Wolfgang.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help