Skip to contentSkip to conversation

team: replace kmalloc+memcpy by kmemdup

PATCH Applied Jiri Pirko 2 participants 2 messages Nov 17, 2011 – Nov 18, 2011

Subsystems (3)
lore
Share & tools
lore

Jiri Pirko

author
#0 lore raw

PATCH 1/1 team: replace kmalloc+memcpy by kmemdup

---
 drivers/net/team/team.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)
drivers/net/team/team.c +2 -6
index c48ef19..064155d 100644
@@ -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++)
Signature · 1 line
1.7.6