Skip to contentSkip to conversation

mptcp: Miscellaneous cleanup

PATCH Applied Mat Martineau 2 participants 4 messages Dec 9, 2022 – Dec 10, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover mptcp: Miscellaneous cleanup

Two code cleanup patches for the 6.2 merge window that don't change behavior:

Patch 1 makes proper use of nlmsg_free(), as suggested by Jakub while reviewing f8c9dfbd875b ("mptcp: add pm listener events").

Patch 2 clarifies success status in a few mptcp functions, which prevents some smatch false positives.

Geliang Tang (1):
mptcp: use nlmsg_free instead of kfree_skb

Matthieu Baerts (1):
mptcp: return 0 instead of 'err' var

 net/mptcp/pm_netlink.c | 12 ++++++------
 net/mptcp/sockopt.c    |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

base-commit: ff36c447e2330625066d193a25a8f94c1408d9d9

Signature · 1 line
2.38.1
#1 lore raw

PATCH 1/2 mptcp: use nlmsg_free instead of kfree_skb

From: Geliang Tang <[email protected]>

Use nlmsg_free() instead of kfree_skb() in pm_netlink.c.

The SKB's have been created by nlmsg_new(). The proper cleaning way should then be done with nlmsg_free().

For the moment, nlmsg_free() is simply calling kfree_skb() so we don't change the behaviour here.

---
 net/mptcp/pm_netlink.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
net/mptcp/pm_netlink.c +4 -4
index eef69d0e44ec..08c65f3e70a3 100644
@@ -2094,7 +2094,7 @@ void mptcp_event_addr_removed(const struct mptcp_sock *msk, uint8_t id)
 	return;
 
 nla_put_failure:
-	kfree_skb(skb);
+	nlmsg_free(skb);
 }
 
 void mptcp_event_addr_announced(const struct sock *ssk,
@@ -2151,7 +2151,7 @@ void mptcp_event_addr_announced(const struct sock *ssk,
 	return;
 
 nla_put_failure:
-	kfree_skb(skb);
+	nlmsg_free(skb);
 }
 
 void mptcp_event_pm_listener(const struct sock *ssk,
@@ -2203,7 +2203,7 @@ void mptcp_event_pm_listener(const struct sock *ssk,
 	return;
 
 nla_put_failure:
-	kfree_skb(skb);
+	nlmsg_free(skb);
 }
 
 void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk,
@@ -2261,7 +2261,7 @@ void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk,
 	return;
 
 nla_put_failure:
-	kfree_skb(skb);
+	nlmsg_free(skb);
 }
 
 static const struct genl_small_ops mptcp_pm_ops[] = {
Signature · 1 line
2.38.1
#2 lore raw

PATCH 2/2 mptcp: return 0 instead of 'err' var

In reply to Mat Martineau

From: Matthieu Baerts <[email protected]>

When 'err' is 0, it looks clearer to return '0' instead of the variable called 'err'.

The behaviour is then not modified, just a clearer code.

By doing this, we can also avoid false positive smatch warnings like this one:

net/mptcp/pm_netlink.c:1169 mptcp_pm_parse_pm_addr_attr() warn: missing error code? 'err'

---
 net/mptcp/pm_netlink.c | 4 ++--
 net/mptcp/sockopt.c    | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
net/mptcp/pm_netlink.c +2 -2
index 08c65f3e70a3..2ea7eae43bdb 100644
@@ -1190,7 +1190,7 @@ static int mptcp_pm_parse_pm_addr_attr(struct nlattr *tb[],
 
 	if (!tb[MPTCP_PM_ADDR_ATTR_FAMILY]) {
 		if (!require_family)
-			return err;
+			return 0;
 
 		NL_SET_ERR_MSG_ATTR(info->extack, attr,
 				    "missing family");
@@ -1224,7 +1224,7 @@ static int mptcp_pm_parse_pm_addr_attr(struct nlattr *tb[],
 	if (tb[MPTCP_PM_ADDR_ATTR_PORT])
 		addr->port = htons(nla_get_u16(tb[MPTCP_PM_ADDR_ATTR_PORT]));
 
-	return err;
+	return 0;
 }
 
 int mptcp_pm_parse_addr(struct nlattr *attr, struct genl_info *info,
net/mptcp/sockopt.c +1 -1
index a47423ebb33a..d4b1e6ec1b36 100644
@@ -740,7 +740,7 @@ static int mptcp_setsockopt_v4_set_tos(struct mptcp_sock *msk, int optname,
 	}
 	release_sock(sk);
 
-	return err;
+	return 0;
 }
 
 static int mptcp_setsockopt_v4(struct mptcp_sock *msk, int optname,
Signature · 1 line
2.38.1
#3 lore raw
In reply to Mat Martineau
This series was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Thu, 8 Dec 2022 16:44:29 -0800 you wrote:

Two code cleanup patches for the 6.2 merge window that don't change behavior:

Patch 1 makes proper use of nlmsg_free(), as suggested by Jakub while reviewing f8c9dfbd875b ("mptcp: add pm listener events").

Patch 2 clarifies success status in a few mptcp functions, which prevents some smatch false positives.

[...]

Here is the summary with links:
- [net-next,1/2] mptcp: use nlmsg_free instead of kfree_skb

    https://git.kernel.org/netdev/net-next/c/8b34b52c1794
  - [net-next,2/2] mptcp: return 0 instead of 'err' var
    https://git.kernel.org/netdev/net-next/c/03e7d28cd25e

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html