From: Liang He <windhl@126.com>
To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, windhl@126.com, netdev@vger.kernel.org
Subject: [PATCH] rionet: Fix refcounting bugs
Date: Tue, 28 Mar 2023 12:50:06 +0800 [thread overview]
Message-ID: <20230328045006.2482327-1-windhl@126.com> (raw)
In rionet_start_xmit(), we should put the refcount_inc()
before we add *skb* into the queue, otherwise it may cause
the consumer to prematurely call refcount_dec().
Besides, before the next rionet_queue_tx_msg() when we
meet the 'RIONET_MAC_MATCH', we should also call
refcount_inc() before the skb is added into the queue.
Fixes: 7c4a6106d645 ("rapidio/rionet: fix multicast packet transmit logic")
Signed-off-by: Liang He <windhl@126.com>
---
drivers/net/rionet.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c
index fbcb9d05da64..72ccbb1aaf11 100644
--- a/drivers/net/rionet.c
+++ b/drivers/net/rionet.c
@@ -195,17 +195,19 @@ static netdev_tx_t rionet_start_xmit(struct sk_buff *skb,
for (i = 0; i < RIO_MAX_ROUTE_ENTRIES(rnet->mport->sys_size);
i++)
if (nets[rnet->mport->id].active[i]) {
- rionet_queue_tx_msg(skb, ndev,
- nets[rnet->mport->id].active[i]);
if (count)
refcount_inc(&skb->users);
count++;
+ rionet_queue_tx_msg(skb, ndev,
+ nets[rnet->mport->id].active[i]);
}
} else if (RIONET_MAC_MATCH(eth->h_dest)) {
destid = RIONET_GET_DESTID(eth->h_dest);
- if (nets[rnet->mport->id].active[destid])
+ if (nets[rnet->mport->id].active[destid]) {
+ refcount_inc(&skb->users);
rionet_queue_tx_msg(skb, ndev,
nets[rnet->mport->id].active[destid]);
+ }
else {
/*
* If the target device was removed from the list of
--
2.25.1
next reply other threads:[~2023-03-28 4:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-28 4:50 Liang He [this message]
2023-03-29 2:10 ` [PATCH] rionet: Fix refcounting bugs Jakub Kicinski
2023-03-29 6:01 ` Liang He
2023-03-29 18:09 ` Simon Horman
2023-03-30 2:09 ` Liang He
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=20230328045006.2482327-1-windhl@126.com \
--to=windhl@126.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.