Skip to content

Commit 2bba19f

Browse files
Jiri Pirkodavem330
authored andcommitted
team: avoid using variable-length array
Apparently using variable-length array is not correct (https://lkml.org/lkml/2011/10/23/25). So remove it. Signed-off-by: Jiri Pirko <jpirko@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 234a8fd commit 2bba19f

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎drivers/net/team/team.c‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,13 @@ int team_options_register(struct team *team,
9696
size_t option_count)
9797
{
9898
int i;
99-
struct team_option *dst_opts[option_count];
99+
struct team_option **dst_opts;
100100
int err;
101101

102-
memset(dst_opts, 0, sizeof(dst_opts));
102+
dst_opts = kzalloc(sizeof(struct team_option *) * option_count,
103+
GFP_KERNEL);
104+
if (!dst_opts)
105+
return -ENOMEM;
103106
for (i = 0; i < option_count; i++, option++) {
104107
struct team_option *dst_opt;
105108

@@ -119,12 +122,14 @@ int team_options_register(struct team *team,
119122
for (i = 0; i < option_count; i++)
120123
list_add_tail(&dst_opts[i]->list, &team->option_list);
121124

125+
kfree(dst_opts);
122126
return 0;
123127

124128
rollback:
125129
for (i = 0; i < option_count; i++)
126130
kfree(dst_opts[i]);
127131

132+
kfree(dst_opts);
128133
return err;
129134
}
130135

0 commit comments

Comments
 (0)