Skip to content

Commit

Permalink
mptcp: use kzalloc in mptcp_pm_nl_get_local_id
Browse files Browse the repository at this point in the history
kzalloc() is used instead of kmalloc() to allocate a new address entry in
mptcp_pm_nl_get_local_id(), so that the code that sets each field of the
entry to zero or NULL can be deleted. If some fields are added or deleted
in struct mptcp_pm_addr_entry in the future, this part of the code does
not need to be modified.

Signed-off-by: Geliang Tang <[email protected]>
  • Loading branch information
Geliang Tang committed Jan 16, 2025
1 parent a189d77 commit e3c5f77
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions net/mptcp/pm_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -1147,16 +1147,14 @@ int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_info *skc
return ret;

/* address not found, add to local list */
entry = kmalloc(sizeof(*entry), GFP_ATOMIC);
entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
if (!entry)
return -ENOMEM;

entry->addr = *skc;
entry->addr.id = 0;
entry->addr.port = 0;
entry->ifindex = 0;
entry->flags = MPTCP_PM_ADDR_FLAG_IMPLICIT;
entry->lsk = NULL;
ret = mptcp_pm_nl_append_new_local_addr(pernet, entry, true);
if (ret < 0)
kfree(entry);
Expand Down

0 comments on commit e3c5f77

Please sign in to comment.