Commit 44194cb1 authored by Lin Ma's avatar Lin Ma Committed by Jakub Kicinski

net: tipc: resize nlattr array to correct size

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: 1e55417d ("tipc: add media set to new netlink api")
Fixes: 46f15c67 ("tipc: add media get/dump to new netlink api")
Signed-off-by: default avatarLin Ma <linma@zju.edu.cn>
Reviewed-by: default avatarFlorian Westphal <fw@strlen.de>
Reviewed-by: default avatarTung Nguyen <tung.q.nguyen@dektech.com.au>
Link: https://lore.kernel.org/r/20230614120604.1196377-1-linma@zju.edu.cnSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent e84a1e1e
...@@ -1258,7 +1258,7 @@ int tipc_nl_media_get(struct sk_buff *skb, struct genl_info *info) ...@@ -1258,7 +1258,7 @@ int tipc_nl_media_get(struct sk_buff *skb, struct genl_info *info)
struct tipc_nl_msg msg; struct tipc_nl_msg msg;
struct tipc_media *media; struct tipc_media *media;
struct sk_buff *rep; 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]) if (!info->attrs[TIPC_NLA_MEDIA])
return -EINVAL; return -EINVAL;
...@@ -1307,7 +1307,7 @@ int __tipc_nl_media_set(struct sk_buff *skb, struct genl_info *info) ...@@ -1307,7 +1307,7 @@ int __tipc_nl_media_set(struct sk_buff *skb, struct genl_info *info)
int err; int err;
char *name; char *name;
struct tipc_media *m; 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]) if (!info->attrs[TIPC_NLA_MEDIA])
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment