From: Wolfgang Grandegger <wg@grandegger.com>
To: Netdev@vger.kernel.org
Cc: Socketcan-core@lists.berlios.de,
Devicetree-discuss@lists.ozlabs.org,
Linuxppc-dev@lists.ozlabs.org, Wolfgang Grandegger <wg@denx.de>
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 [thread overview]
Message-ID: <1262893388-16218-2-git-send-email-wg@grandegger.com> (raw)
In-Reply-To: <1262893388-16218-1-git-send-email-wg@grandegger.com>
From: Wolfgang Grandegger <wg@denx.de>
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>
---
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 <avolkov@varma-el.com>,
* Varma Electronics Oy
* Copyright (C) 2008-2009 Wolfgang Grandegger <wg@grandegger.com>
- * Copytight (C) 2008-2009 Pengutronix <kernel@pengutronix.de>
+ * Copyright (C) 2008-2009 Pengutronix <kernel@pengutronix.de>
*
* 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);
--
1.6.2.5
next prev parent reply other threads:[~2010-01-07 19:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-07 19:43 [PATCH net-next v4 0/3] can: mscan-mpc5xxx: add support for the Freescale MPC512x Wolfgang Grandegger
2010-01-07 19:43 ` Wolfgang Grandegger [this message]
2010-01-07 19:43 ` [PATCH net-next v4 2/3] can: mscan-mpc5xxx: add support for the MPC512x processor Wolfgang Grandegger
2010-01-07 19:43 ` [PATCH net-next v4 3/3] powerpc/mpc5xxx: add OF platform binding doc for FSL MSCAN devices Wolfgang Grandegger
2010-01-08 8:41 ` [PATCH net-next v4 0/3] can: mscan-mpc5xxx: add support for the Freescale MPC512x David Miller
2010-01-08 8:58 ` Wolfgang Grandegger
2010-01-08 9:02 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1262893388-16218-2-git-send-email-wg@grandegger.com \
--to=wg@grandegger.com \
--cc=Devicetree-discuss@lists.ozlabs.org \
--cc=Linuxppc-dev@lists.ozlabs.org \
--cc=Netdev@vger.kernel.org \
--cc=Socketcan-core@lists.berlios.de \
--cc=wg@denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).