Skip to content

Commit

Permalink
team: avoid using variable-length array
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jiri Pirko authored and David S. Miller committed Nov 18, 2011
1 parent 234a8fd commit 2bba19f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions drivers/net/team/team.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,13 @@ int team_options_register(struct team *team,
size_t option_count)
{
int i;
struct team_option *dst_opts[option_count];
struct team_option **dst_opts;
int err;

memset(dst_opts, 0, sizeof(dst_opts));
dst_opts = kzalloc(sizeof(struct team_option *) * option_count,
GFP_KERNEL);
if (!dst_opts)
return -ENOMEM;
for (i = 0; i < option_count; i++, option++) {
struct team_option *dst_opt;

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

kfree(dst_opts);
return 0;

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

kfree(dst_opts);
return err;
}

Expand Down

0 comments on commit 2bba19f

Please sign in to comment.