netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Marek Vasut <marex@denx.de>
Cc: netdev@vger.kernel.org, f.fainelli@gmail.com,
	Tristram Ha <Tristram.Ha@microchip.com>,
	Vivien Didelot <vivien.didelot@savoirfairelinux.com>,
	Woojung Huh <woojung.huh@microchip.com>,
	"David S . Miller" <davem@davemloft.net>
Subject: Re: [PATCH V2 2/3] net: dsa: ksz: Factor out common tag code
Date: Fri, 14 Dec 2018 21:11:35 +0100	[thread overview]
Message-ID: <20181214201135.GB21591@lunn.ch> (raw)
In-Reply-To: <4ff4924c-415a-9555-762f-151d83035dab@denx.de>

On Fri, Dec 14, 2018 at 02:30:35PM +0100, Marek Vasut wrote:
> On 12/14/2018 10:05 AM, Andrew Lunn wrote:
> >> +static struct sk_buff *ksz_common_xmit(struct sk_buff *skb,
> >> +				       struct net_device *dev, int len)
> >>  {
> >> -	struct dsa_port *dp = dsa_slave_to_port(dev);
> >>  	struct sk_buff *nskb;
> >>  	int padlen;
> >> -	u8 *tag;
> >>  
> >>  	padlen = (skb->len >= ETH_ZLEN) ? 0 : ETH_ZLEN - skb->len;
> >>  
> >> -	if (skb_tailroom(skb) >= padlen + KSZ_INGRESS_TAG_LEN) {
> >> +	if (skb_tailroom(skb) >= padlen + len) {
> >>  		/* Let dsa_slave_xmit() free skb */
> >>  		if (__skb_put_padto(skb, skb->len + padlen, false))
> >>  			return NULL;
> > 
> > Hi Marek
> 
> Hi,
> 
> > This can return NULL.
> > 
> >> +static struct sk_buff *ksz9477_xmit(struct sk_buff *skb,
> >> +				    struct net_device *dev)
> >> +{
> >> +	struct dsa_port *dp = dsa_slave_to_port(dev);
> >> +	struct sk_buff *nskb;
> >> +	u16 *tag;
> >> +	u8 *addr;
> >> +
> >> +	nskb = ksz_common_xmit(skb, dev, KSZ9477_INGRESS_TAG_LEN);
> > 
> > So here you need to check for NULL
> 
> What do we do if the xmit returns NULL ?

Return NULL to the caller. There are comments which explain this:

static netdev_tx_t dsa_slave_xmit(struct sk_buff *skb, struct net_device *dev)
{
[snip]
        /* Transmit function may have to reallocate the original SKB,
         * in which case it must have freed it. Only free it here on error.
         */
        nskb = p->xmit(skb, dev);
        if (!nskb) {
                kfree_skb(skb);
                return NETDEV_TX_OK;
        }

	Andrew

  reply	other threads:[~2018-12-14 20:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-13 16:01 [PATCH V2 0/3] net: dsa: ksz: Clean up the tag code in prep for more switches Marek Vasut
2018-12-13 16:01 ` [PATCH V2 1/3] net: dsa: ksz: Rename NET_DSA_TAG_KSZ to _KSZ9477 Marek Vasut
2018-12-14  8:42   ` Andrew Lunn
2018-12-13 16:01 ` [PATCH V2 2/3] net: dsa: ksz: Factor out common tag code Marek Vasut
2018-12-14  9:05   ` Andrew Lunn
2018-12-14 13:30     ` Marek Vasut
2018-12-14 20:11       ` Andrew Lunn [this message]
2018-12-15  0:39         ` Marek Vasut
2018-12-13 16:01 ` [PATCH V2 3/3] net: dsa: ksz: Add STP multicast handling Marek Vasut
2018-12-14  9:07   ` Andrew Lunn

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=20181214201135.GB21591@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=Tristram.Ha@microchip.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=marex@denx.de \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@savoirfairelinux.com \
    --cc=woojung.huh@microchip.com \
    /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).