From: Matt Johnston <matt@codeconstruct.com.au>
To: netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Jeremy Kerr <jk@codeconstruct.com.au>
Subject: [PATCH net-next v3 2/2] mctp: Fix incorrect netdev unref for extended addr
Date: Tue, 22 Feb 2022 12:17:39 +0800 [thread overview]
Message-ID: <20220222041739.511255-3-matt@codeconstruct.com.au> (raw)
In-Reply-To: <20220222041739.511255-1-matt@codeconstruct.com.au>
In the extended addressing local route output codepath
dev_get_by_index_rcu() doesn't take a dev_hold() so we shouldn't
dev_put().
Signed-off-by: Matt Johnston <matt@codeconstruct.com.au>
---
net/mctp/route.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/net/mctp/route.c b/net/mctp/route.c
index 6f277e56b168..5078ce3315cf 100644
--- a/net/mctp/route.c
+++ b/net/mctp/route.c
@@ -838,7 +838,6 @@ int mctp_local_output(struct sock *sk, struct mctp_route *rt,
struct mctp_skb_cb *cb = mctp_cb(skb);
struct mctp_route tmp_rt = {0};
struct mctp_sk_key *key;
- struct net_device *dev;
struct mctp_hdr *hdr;
unsigned long flags;
unsigned int mtu;
@@ -851,12 +850,12 @@ int mctp_local_output(struct sock *sk, struct mctp_route *rt,
if (rt) {
ext_rt = false;
- dev = NULL;
-
if (WARN_ON(!rt->dev))
goto out_release;
} else if (cb->ifindex) {
+ struct net_device *dev;
+
ext_rt = true;
rt = &tmp_rt;
@@ -866,7 +865,6 @@ int mctp_local_output(struct sock *sk, struct mctp_route *rt,
rcu_read_unlock();
return rc;
}
-
rt->dev = __mctp_dev_get(dev);
rcu_read_unlock();
@@ -947,11 +945,9 @@ int mctp_local_output(struct sock *sk, struct mctp_route *rt,
if (!ext_rt)
mctp_route_release(rt);
- dev_put(dev);
mctp_dev_put(tmp_rt.dev);
return rc;
-
}
/* route management */
--
2.32.0
next prev parent reply other threads:[~2022-02-22 4:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-22 4:17 [PATCH net-next v3 0/2] mctp: Fix incorrect refs for extended addr Matt Johnston
2022-02-22 4:17 ` [PATCH net-next v3 1/2] mctp: make __mctp_dev_get() take a refcount hold Matt Johnston
2022-02-23 3:59 ` Jakub Kicinski
2022-02-23 4:22 ` Jeremy Kerr
2022-02-22 4:17 ` Matt Johnston [this message]
2022-02-23 12:30 ` [PATCH net-next v3 0/2] mctp: Fix incorrect refs for extended addr 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=20220222041739.511255-3-matt@codeconstruct.com.au \
--to=matt@codeconstruct.com.au \
--cc=davem@davemloft.net \
--cc=jk@codeconstruct.com.au \
--cc=kuba@kernel.org \
--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).