Skip to content

Commit

Permalink
net: ipa: skip SKB copy if no netdev
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Alex Elder authored and kuba-moo committed Nov 26, 2021
1 parent 01c3663 commit 1b65bbc
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions drivers/net/ipa/ipa_endpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 1b65bbc

Please sign in to comment.