Skip to content

Commit

Permalink
net: tipc: resize nlattr array to correct size
Browse files Browse the repository at this point in the history
According to nla_parse_nested_deprecated(), the tb[] is supposed to the
destination array with maxtype+1 elements. In current
tipc_nl_media_get() and __tipc_nl_media_set(), a larger array is used
which is unnecessary. This patch resize them to a proper size.

Fixes: 1e55417 ("tipc: add media set to new netlink api")
Fixes: 46f15c6 ("tipc: add media get/dump to new netlink api")
Signed-off-by: Lin Ma <[email protected]>
Reviewed-by: Florian Westphal <[email protected]>
Reviewed-by: Tung Nguyen <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
f0rm2l1n authored and kuba-moo committed Jun 15, 2023
1 parent e84a1e1 commit 44194cb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/tipc/bearer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,7 @@ int tipc_nl_media_get(struct sk_buff *skb, struct genl_info *info)
struct tipc_nl_msg msg;
struct tipc_media *media;
struct sk_buff *rep;
struct nlattr *attrs[TIPC_NLA_BEARER_MAX + 1];
struct nlattr *attrs[TIPC_NLA_MEDIA_MAX + 1];

if (!info->attrs[TIPC_NLA_MEDIA])
return -EINVAL;
Expand Down Expand Up @@ -1307,7 +1307,7 @@ int __tipc_nl_media_set(struct sk_buff *skb, struct genl_info *info)
int err;
char *name;
struct tipc_media *m;
struct nlattr *attrs[TIPC_NLA_BEARER_MAX + 1];
struct nlattr *attrs[TIPC_NLA_MEDIA_MAX + 1];

if (!info->attrs[TIPC_NLA_MEDIA])
return -EINVAL;
Expand Down

0 comments on commit 44194cb

Please sign in to comment.