public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Oliver Hartkopp <socketcan-fJ+pQTUTwRTk1uMJSBkQmQ@public•gmane.org>
To: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public•gmane.org>
Cc: Netdev-u79uwXL29TY76Z2rM5mHXA@public•gmane.org,
	Devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public•gmane.org,
	Socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public•gmane.org,
	Linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ@public•gmane.org,
	Wolfgang Grandegger <wg-ynQEQJNshbs@public•gmane.org>
Subject: Re: [PATCH net-next v3 1/3] can: mscan: fix improper return if dlc < 8 in start_xmit function
Date: Thu, 07 Jan 2010 19:10:38 +0100	[thread overview]
Message-ID: <4B46239E.2000403@hartkopp.net> (raw)
In-Reply-To: <1262873421-6863-2-git-send-email-wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>

Wolfgang Grandegger wrote:

> 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. 

> @@ -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 packet: len %u, can_dlc %u\n",
> +			skb->len, frame->can_dlc);
> +		kfree_skb(skb);
> +		return NETDEV_TX_OK;
> +	}
>  

Hi Wolfgang,

i would suggest to remove the dev_err() which may flood the kernel log and add

   dev->stats.tx_dropped++;

instead.

As discussed with DaveM on netdev-ML this 'silent' handling seems to be the
most appropriate approach to deal with invalid skbs.

We should update the other CAN drivers in a similar way, if this is ok for you.

Best regards,
Oliver

      parent reply	other threads:[~2010-01-07 18:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-07 14:10 [PATCH net-next v3 0/3] can: mscan-mpc5xxx: add support for the Freescale MPC512x Wolfgang Grandegger
2010-01-07 14:10 ` [PATCH net-next v3 1/3] can: mscan: fix improper return if dlc < 8 in start_xmit function Wolfgang Grandegger
2010-01-07 14:10   ` [PATCH net-next v3 2/3] can: mscan-mpc5xxx: add support for the MPC512x processor Wolfgang Grandegger
2010-01-07 14:10     ` [PATCH net-next v3 3/3] powerpc/mpc5xxx: add OF platform binding doc for FSL MSCAN devices Wolfgang Grandegger
     [not found]     ` <1262873421-6863-3-git-send-email-wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2010-01-07 16:21       ` [PATCH net-next v3 2/3] can: mscan-mpc5xxx: add support for the MPC512x processor Wolfram Sang
     [not found]   ` <1262873421-6863-2-git-send-email-wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2010-01-07 18:10     ` Oliver Hartkopp [this message]

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=4B46239E.2000403@hartkopp.net \
    --to=socketcan-fj+pqtutwrtk1umjsbkqmq@public$(echo .)gmane.org \
    --cc=Devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public$(echo .)gmane.org \
    --cc=Linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ@public$(echo .)gmane.org \
    --cc=Netdev-u79uwXL29TY76Z2rM5mHXA@public$(echo .)gmane.org \
    --cc=Socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public$(echo .)gmane.org \
    --cc=wg-5Yr1BZd7O62+XT7JhA+gdA@public$(echo .)gmane.org \
    --cc=wg-ynQEQJNshbs@public$(echo .)gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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