LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Alex Elder <elder@linaro.org>
To: davem@davemloft.net, kuba@kernel.org
Cc: pkurapat@codeaurora.org, avuyyuru@codeaurora.org,
	bjorn.andersson@linaro.org, cpratapa@codeaurora.org,
	subashab@codeaurora.org, evgreen@chromium.org, elder@kernel.org,
	netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH net-next 5/7] net: ipa: skip SKB copy if no netdev
Date: Wed, 24 Nov 2021 14:25:09 -0600	[thread overview]
Message-ID: <20211124202511.862588-6-elder@linaro.org> (raw)
In-Reply-To: <20211124202511.862588-1-elder@linaro.org>

In ipa_endpoint_skb_copy(), a new socket buffer structure is
allocated so that some data can be copied into it.  However, after
doing this, if the endpoint has a null netdev pointer, we just drop
free the socket buffer.

Instead, check endpoint->netdev pointer first, and just return early
if it's null.  Also return early if the SKB allocation fails, to
avoid the deeper indentation in the normal path.

Signed-off-by: Alex Elder <elder@linaro.org>
---
 drivers/net/ipa/ipa_endpoint.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c
index eeb9f082a0e4c..fba576a7717fa 100644
--- a/drivers/net/ipa/ipa_endpoint.c
+++ b/drivers/net/ipa/ipa_endpoint.c
@@ -1153,18 +1153,19 @@ static void ipa_endpoint_skb_copy(struct ipa_endpoint *endpoint,
 {
 	struct sk_buff *skb;
 
+	if (!endpoint->netdev)
+		return;
+
 	skb = __dev_alloc_skb(len, GFP_ATOMIC);
-	if (skb) {
-		skb_put(skb, len);
-		memcpy(skb->data, data, len);
-		skb->truesize += extra;
-	}
+	if (!skb)
+		return;
 
-	/* Now receive it, or drop it if there's no netdev */
-	if (endpoint->netdev)
-		ipa_modem_skb_rx(endpoint->netdev, skb);
-	else if (skb)
-		dev_kfree_skb_any(skb);
+	/* Copy the data into the socket buffer and receive it */
+	skb_put(skb, len);
+	memcpy(skb->data, data, len);
+	skb->truesize += extra;
+
+	ipa_modem_skb_rx(endpoint->netdev, skb);
 }
 
 static bool ipa_endpoint_skb_build(struct ipa_endpoint *endpoint,
-- 
2.32.0


  parent reply	other threads:[~2021-11-24 20:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-24 20:25 [PATCH net-next 0/7] net: ipa: small collected improvements Alex Elder
2021-11-24 20:25 ` [PATCH net-next 1/7] net: ipa: kill ipa_modem_init() Alex Elder
2021-11-24 20:25 ` [PATCH net-next 2/7] net: ipa: zero unused portions of filter table memory Alex Elder
2021-11-24 20:25 ` [PATCH net-next 3/7] net: ipa: rework how HOL_BLOCK handling is specified Alex Elder
2021-11-24 20:25 ` [PATCH net-next 4/7] net: ipa: explicitly disable HOLB drop during setup Alex Elder
2021-11-24 20:25 ` Alex Elder [this message]
2021-11-24 20:25 ` [PATCH net-next 6/7] net: ipa: GSI only needs one completion Alex Elder
2021-11-24 20:25 ` [PATCH net-next 7/7] net: ipa: rearrange GSI structure fields Alex Elder
2021-11-26  3:50 ` [PATCH net-next 0/7] net: ipa: small collected improvements patchwork-bot+netdevbpf

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=20211124202511.862588-6-elder@linaro.org \
    --to=elder@linaro.org \
    --cc=avuyyuru@codeaurora.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=cpratapa@codeaurora.org \
    --cc=davem@davemloft.net \
    --cc=elder@kernel.org \
    --cc=evgreen@chromium.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pkurapat@codeaurora.org \
    --cc=subashab@codeaurora.org \
    --subject='Re: [PATCH net-next 5/7] net: ipa: skip SKB copy if no netdev' \
    /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

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