netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Alexander Duyck <alexander.h.duyck@intel.com>
Cc: netdev@vger.kernel.org, linux-wireless@vger.kernel.org,
	davem@davemloft.net, linville@tuxdriver.com
Subject: Re: [PATCH net-next] mac80211: Check correct skb for shared states before freeing original
Date: Wed, 10 Sep 2014 22:33:07 +0200	[thread overview]
Message-ID: <1410381187.2761.10.camel@jlt4.sipsolutions.net> (raw)
In-Reply-To: <20140910200442.15961.84466.stgit@ahduyck-bv4.jf.intel.com> (sfid-20140910_221517_589456_8B140F20)

On Wed, 2014-09-10 at 16:06 -0400, Alexander Duyck wrote:
> The code for cloning the skb for an acknowledgement was checking to see if
> the cloned skb was shared and if it was it was then freeing the original
> skb.  Since a clone should never really be shared I suspect that the
> intention was to avoid freeing the clone if the original was shared.  As
> such I am updating the code so that if the original is shared we free the
> original and use the clone.  This avoids unnecessary work in the next
> section where we would be cloning the skb if the original is shared.

Thanks, yeah, I admit that this is clearly fishy.

> @@ -2087,7 +2087,7 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
>  			if (id >= 0) {
>  				info_id = id;
>  				info_flags |= IEEE80211_TX_CTL_REQ_TX_STATUS;

Luckily, we practically always go into this path.

> -			} else if (skb_shared(skb)) {
> +			} else if (skb_shared(orig_skb)) {
>  				kfree_skb(orig_skb);
>  			} else {
>  				kfree_skb(skb);

We have a clone already so we could just remove the whole "else if" I
think, but I'm guessing my intent was to keep it accounted to the socket
where possible rather than freeing the original in all cases.

So yeah, I think this makes sense. Maybe we should add a comment to the
if though to explain this?

johannes

  reply	other threads:[~2014-09-10 20:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-10 20:06 [PATCH net-next] mac80211: Check correct skb for shared states before freeing original Alexander Duyck
2014-09-10 20:33 ` Johannes Berg [this message]
2014-09-10 21:01   ` Alexander Duyck

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=1410381187.2761.10.camel@jlt4.sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=alexander.h.duyck@intel.com \
    --cc=davem@davemloft.net \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --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).