]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
team: avoid using variable-length array
authorJiri Pirko <jpirko@redhat.com>
Thu, 17 Nov 2011 04:16:05 +0000 (04:16 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 18 Nov 2011 19:55:00 +0000 (14:55 -0500)
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>
drivers/net/team/team.c

index 5b169c18aaf680dadd5238f14ac9f315cf52bf33..c48ef19cac136b9b538eefd960d260ce92d6f6e1 100644 (file)
@@ -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;
 
@@ -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;
 }