Commit 2cdc7241 authored by Li Zefan's avatar Li Zefan Committed by Linus Torvalds
Browse files

devcgroup: use kmemdup()



This saves 40 bytes on my x86_32 box.

Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
Acked-by: default avatarSerge Hallyn <serue@us.ibm.com>
Cc: Paul Menage <menage@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 886465f4
Loading
Loading
Loading
Loading
+2 −7
Original line number Original line Diff line number Diff line
@@ -84,13 +84,9 @@ static int dev_whitelist_copy(struct list_head *dest, struct list_head *orig)
	struct dev_whitelist_item *wh, *tmp, *new;
	struct dev_whitelist_item *wh, *tmp, *new;


	list_for_each_entry(wh, orig, list) {
	list_for_each_entry(wh, orig, list) {
		new = kmalloc(sizeof(*wh), GFP_KERNEL);
		new = kmemdup(wh, sizeof(*wh), GFP_KERNEL);
		if (!new)
		if (!new)
			goto free_and_exit;
			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);
		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;
	struct dev_whitelist_item *whcopy, *walk;


	whcopy = kmalloc(sizeof(*whcopy), GFP_KERNEL);
	whcopy = kmemdup(wh, sizeof(*wh), GFP_KERNEL);
	if (!whcopy)
	if (!whcopy)
		return -ENOMEM;
		return -ENOMEM;


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