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 c48ef19cac136b9b538eefd960d260ce92d6f6e1..064155d56bce2deeb6b14755429a6c6d5c22240a 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++)