aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/team/team.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/team/team.c')
-rw-r--r--drivers/net/team/team.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index 5b169c18aaf6..c48ef19cac13 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -96,10 +96,13 @@ int team_options_register(struct team *team,
96 size_t option_count) 96 size_t option_count)
97{ 97{
98 int i; 98 int i;
99 struct team_option *dst_opts[option_count]; 99 struct team_option **dst_opts;
100 int err; 100 int err;
101 101
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;
103 for (i = 0; i < option_count; i++, option++) { 106 for (i = 0; i < option_count; i++, option++) {
104 struct team_option *dst_opt; 107 struct team_option *dst_opt;
105 108
@@ -119,12 +122,14 @@ int team_options_register(struct team *team,
119 for (i = 0; i < option_count; i++) 122 for (i = 0; i < option_count; i++)
120 list_add_tail(&dst_opts[i]->list, &team->option_list); 123 list_add_tail(&dst_opts[i]->list, &team->option_list);
121 124
125 kfree(dst_opts);
122 return 0; 126 return 0;
123 127
124rollback: 128rollback:
125 for (i = 0; i < option_count; i++) 129 for (i = 0; i < option_count; i++)
126 kfree(dst_opts[i]); 130 kfree(dst_opts[i]);
127 131
132 kfree(dst_opts);
128 return err; 133 return err;
129} 134}
130 135