netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <dada1@cosmosbay.com>
To: Dave Jones <davej@redhat.com>
Cc: David Miller <davem@davemloft.net>, netdev@vger.kernel.org
Subject: Re: VIA velocity skb leak.
Date: Thu, 12 Mar 2009 06:14:27 +0100	[thread overview]
Message-ID: <49B89A33.2030207@cosmosbay.com> (raw)
In-Reply-To: <20090312045657.GB7132@redhat.com>

Dave Jones a écrit :
> On Thu, Mar 12, 2009 at 05:45:57AM +0100, Eric Dumazet wrote:
> 
>  > > @@ -1845,10 +1846,11 @@ static void velocity_free_tx_buf(struct velocity_info *vptr, struct velocity_td_
>  > >  	if (tdinfo->skb_dma) {
>  > >  
>  > > +		pktlen = (skb->len > ETH_ZLEN ? : ETH_ZLEN);
>  > 
>  > I personally find better to use max(skb->len, ETH_ZLEN) macro, but YMMV ;)
>  > 
>  > It actually can avoid you a bug ;)
>  
> I prefer that too, but it makes a warning.
> 
> drivers/net/via-velocity.c:2093: warning: comparison of distinct pointer types lacks a cast
> 
> We can fix this by either casting ETH_ZLEN to an unsigned int,
> or we could just do the diff below..
> 
> Or did I overlook something?
> 
> (if this looks ok, perhaps the other defines could use the same treatment?)
> 
> 	Dave
> 
> The minimum frame length is never signed, define it as
> such so we don't need excessive casts in comparisons.
> 
> Signed-off-by: Dave Jones <davej@redhat.com>
> 
> diff --git a/include/linux/if_ether.h b/include/linux/if_ether.h
> index 7f3c735..c41183e 100644
> --- a/include/linux/if_ether.h
> +++ b/include/linux/if_ether.h
> @@ -30,7 +30,7 @@
>  
>  #define ETH_ALEN	6		/* Octets in one ethernet addr	 */
>  #define ETH_HLEN	14		/* Total octets in header.	 */
> -#define ETH_ZLEN	60		/* Min. octets in frame sans FCS */
> +#define ETH_ZLEN	60U		/* Min. octets in frame sans FCS */
>  #define ETH_DATA_LEN	1500		/* Max. octets in payload	 */
>  #define ETH_FRAME_LEN	1514		/* Max. octets in frame sans FCS */
>  #define ETH_FCS_LEN	4		/* Octets in the FCS		 */
> 

or use max_t(unsigned, skb->len, ETH_ZLEN)


  reply	other threads:[~2009-03-12  5:15 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-12  4:13 VIA velocity skb leak Dave Jones
2009-03-12  4:17 ` David Miller
2009-03-12  4:20   ` David Miller
2009-03-12  4:39     ` Dave Jones
2009-03-12  4:45       ` Eric Dumazet
2009-03-12  4:56         ` Dave Jones
2009-03-12  5:14           ` Eric Dumazet [this message]
2009-03-13 20:36             ` David Miller
2009-03-13 20:52               ` a2065 skb_padto cleanups Dave Jones
2009-03-19  1:18                 ` David Miller
2009-03-13 21:10               ` r8169 skb leak Dave Jones
2009-03-13 22:26                 ` Francois Romieu
2009-03-13 22:33                   ` 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=49B89A33.2030207@cosmosbay.com \
    --to=dada1@cosmosbay.com \
    --cc=davej@redhat.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /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).