team: replace kmalloc+memcpy by kmemdup
authorJiri Pirko <jpirko@redhat.com>
Thu, 17 Nov 2011 06:32:37 +0000 (06:32 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 18 Nov 2011 19:55:03 +0000 (14:55 -0500)
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/team/team.c

index c48ef19..064155d 100644 (file)
@@ -104,19 +104,15 @@ int team_options_register(struct team *team,
        if (!dst_opts)
                return -ENOMEM;
        for (i = 0; i < option_count; i++, option++) {
-               struct team_option *dst_opt;
-
                if (__team_find_option(team, option->name)) {
                        err = -EEXIST;
                        goto rollback;
                }
-               dst_opt = kmalloc(sizeof(*option), GFP_KERNEL);
-               if (!dst_opt) {
+               dst_opts[i] = kmemdup(option, sizeof(*option), GFP_KERNEL);
+               if (!dst_opts[i]) {
                        err = -ENOMEM;
                        goto rollback;
                }
-               memcpy(dst_opt, option, sizeof(*option));
-               dst_opts[i] = dst_opt;
        }
 
        for (i = 0; i < option_count; i++)