Message ID | 7353b0ca7f73188dbbb24b9e1fcb0fd4620a8d25.1627559076.git.geliangtang@xiaomi.com (mailing list archive) |
---|---|
State | Accepted, archived |
Commit | 22876224b52776ecffe342b8fe24d2aebeb6baff |
Delegated to: | Matthieu Baerts |
Headers | show |
Series | [v4,mptcp-next] Squash to "mptcp: drop flags and ifindex arguments" | expand |
On Thu, 29 Jul 2021, Geliang Tang wrote: > From: Geliang Tang <geliangtang@xiaomi.com> > > Fix rcu section and add the non-zero id check. > Looks good to squash, thanks. -Mat > Signed-off-by: Geliang Tang <geliangtang@xiaomi.com> > --- > net/mptcp/pm_netlink.c | 21 +++++++++++---------- > 1 file changed, 11 insertions(+), 10 deletions(-) > > diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c > index 94c68d6093de..47200ae451b9 100644 > --- a/net/mptcp/pm_netlink.c > +++ b/net/mptcp/pm_netlink.c > @@ -1107,16 +1107,17 @@ int mptcp_pm_get_flags_and_ifindex_by_id(struct net *net, unsigned int id, > { > struct mptcp_pm_addr_entry *entry; > > - rcu_read_lock(); > - entry = __lookup_addr_by_id(net_generic(net, pm_nl_pernet_id), id); > - rcu_read_unlock(); > - > - if (entry) { > - *flags = entry->flags; > - *ifindex = entry->ifindex; > - } else { > - *flags = 0; > - *ifindex = 0; > + *flags = 0; > + *ifindex = 0; > + > + if (id) { > + rcu_read_lock(); > + entry = __lookup_addr_by_id(net_generic(net, pm_nl_pernet_id), id); > + if (entry) { > + *flags = entry->flags; > + *ifindex = entry->ifindex; > + } > + rcu_read_unlock(); > } > > return 0; > -- > 2.31.1 > > > -- Mat Martineau Intel
diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 94c68d6093de..47200ae451b9 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1107,16 +1107,17 @@ int mptcp_pm_get_flags_and_ifindex_by_id(struct net *net, unsigned int id, { struct mptcp_pm_addr_entry *entry; - rcu_read_lock(); - entry = __lookup_addr_by_id(net_generic(net, pm_nl_pernet_id), id); - rcu_read_unlock(); - - if (entry) { - *flags = entry->flags; - *ifindex = entry->ifindex; - } else { - *flags = 0; - *ifindex = 0; + *flags = 0; + *ifindex = 0; + + if (id) { + rcu_read_lock(); + entry = __lookup_addr_by_id(net_generic(net, pm_nl_pernet_id), id); + if (entry) { + *flags = entry->flags; + *ifindex = entry->ifindex; + } + rcu_read_unlock(); } return 0;