Skip to content

Commit fa7360e

Browse files
Geliang Tangintel-lab-lkp
authored andcommitted
mptcp: pm: userspace: use sock_kmemdup helper
Instead of using sock_kmalloc() to allocate an entry and then immediately duplicate another entry to the newly allocated one, sock_kmemdup() helper can be used to simplify the code. More importantly, the code "*e = *entry;" that assigns "entry" to "e" is not easy to implemented in BPF if we use the same code to implement an append_new_local_addr() helper of a BFP path manager. This patch avoids this type of memory assignment operation. Signed-off-by: Geliang Tang <[email protected]>
1 parent f6c8a35 commit fa7360e

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

net/mptcp/pm_userspace.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,12 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk,
7171
/* Memory for the entry is allocated from the
7272
* sock option buffer.
7373
*/
74-
e = sock_kmalloc(sk, sizeof(*e), GFP_ATOMIC);
74+
e = sock_kmemdup(sk, entry, sizeof(*entry), GFP_ATOMIC);
7575
if (!e) {
7676
ret = -ENOMEM;
7777
goto append_err;
7878
}
7979

80-
*e = *entry;
8180
if (!e->addr.id && needs_id)
8281
e->addr.id = find_next_zero_bit(id_bitmap,
8382
MPTCP_PM_MAX_ADDR_ID + 1,

0 commit comments

Comments
 (0)