Skip to content

Commit 2cdc724

Browse files
Li Zefantorvalds
authored andcommitted
devcgroup: use kmemdup()
This saves 40 bytes on my x86_32 box. Signed-off-by: Li Zefan <lizf@cn.fujitsu.com> Acked-by: Serge Hallyn <serue@us.ibm.com> Cc: Paul Menage <menage@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 886465f commit 2cdc724

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

security/device_cgroup.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,9 @@ static int dev_whitelist_copy(struct list_head *dest, struct list_head *orig)
8484
struct dev_whitelist_item *wh, *tmp, *new;
8585

8686
list_for_each_entry(wh, orig, list) {
87-
new = kmalloc(sizeof(*wh), GFP_KERNEL);
87+
new = kmemdup(wh, sizeof(*wh), GFP_KERNEL);
8888
if (!new)
8989
goto free_and_exit;
90-
new->major = wh->major;
91-
new->minor = wh->minor;
92-
new->type = wh->type;
93-
new->access = wh->access;
9490
list_add_tail(&new->list, dest);
9591
}
9692

@@ -114,11 +110,10 @@ static int dev_whitelist_add(struct dev_cgroup *dev_cgroup,
114110
{
115111
struct dev_whitelist_item *whcopy, *walk;
116112

117-
whcopy = kmalloc(sizeof(*whcopy), GFP_KERNEL);
113+
whcopy = kmemdup(wh, sizeof(*wh), GFP_KERNEL);
118114
if (!whcopy)
119115
return -ENOMEM;
120116

121-
memcpy(whcopy, wh, sizeof(*whcopy));
122117
spin_lock(&dev_cgroup->lock);
123118
list_for_each_entry(walk, &dev_cgroup->whitelist, list) {
124119
if (walk->type != wh->type)

0 commit comments

Comments
 (0)