devcgroup: use kmemdup()
authorLi Zefan <[email protected]>
Sun, 19 Oct 2008 03:28:06 +0000 (20:28 -0700)
committerLinus Torvalds <[email protected]>
Mon, 20 Oct 2008 15:52:38 +0000 (08:52 -0700)
This saves 40 bytes on my x86_32 box.

Signed-off-by: Li Zefan <[email protected]>
Acked-by: Serge Hallyn <[email protected]>
Cc: Paul Menage <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
security/device_cgroup.c

index 46f23971f7e4208d9487cbb9cf477790a8fb378a..9c625f65ee5615b05ad35cf8f61cc1d1e1000130 100644 (file)
@@ -84,13 +84,9 @@ static int dev_whitelist_copy(struct list_head *dest, struct list_head *orig)
        struct dev_whitelist_item *wh, *tmp, *new;
 
        list_for_each_entry(wh, orig, list) {
-               new = kmalloc(sizeof(*wh), GFP_KERNEL);
+               new = kmemdup(wh, sizeof(*wh), GFP_KERNEL);
                if (!new)
                        goto free_and_exit;
-               new->major = wh->major;
-               new->minor = wh->minor;
-               new->type = wh->type;
-               new->access = wh->access;
                list_add_tail(&new->list, dest);
        }
 
@@ -114,11 +110,10 @@ static int dev_whitelist_add(struct dev_cgroup *dev_cgroup,
 {
        struct dev_whitelist_item *whcopy, *walk;
 
-       whcopy = kmalloc(sizeof(*whcopy), GFP_KERNEL);
+       whcopy = kmemdup(wh, sizeof(*wh), GFP_KERNEL);
        if (!whcopy)
                return -ENOMEM;
 
-       memcpy(whcopy, wh, sizeof(*whcopy));
        spin_lock(&dev_cgroup->lock);
        list_for_each_entry(walk, &dev_cgroup->whitelist, list) {
                if (walk->type != wh->type)