All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] devcgroup: use kmemdup()
@ 2008-08-25  2:22 Li Zefan
       [not found] ` <48B21756.4020208-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
  2008-08-25 16:43 ` Serge E. Hallyn
  0 siblings, 2 replies; 4+ messages in thread
From: Li Zefan @ 2008-08-25  2:22 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Serge E. Hallyn, Paul Menage, LKML, Linux Containers

This saves 40 bytes on my x86_32 box.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 security/device_cgroup.c |    9 ++-------
 1 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/security/device_cgroup.c b/security/device_cgroup.c
index 46f2397..9c625f6 100644
--- a/security/device_cgroup.c
+++ b/security/device_cgroup.c
@@ -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)
-- 
1.5.4.rc3

^ permalink raw reply related	[flat|nested] 4+ messages in thread
* [PATCH] devcgroup: use kmemdup()
@ 2008-08-25  2:22 Li Zefan
  0 siblings, 0 replies; 4+ messages in thread
From: Li Zefan @ 2008-08-25  2:22 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Paul Menage, Linux Containers, LKML

This saves 40 bytes on my x86_32 box.

Signed-off-by: Li Zefan <lizf-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
---
 security/device_cgroup.c |    9 ++-------
 1 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/security/device_cgroup.c b/security/device_cgroup.c
index 46f2397..9c625f6 100644
--- a/security/device_cgroup.c
+++ b/security/device_cgroup.c
@@ -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)
-- 
1.5.4.rc3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-08-25 16:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-25  2:22 [PATCH] devcgroup: use kmemdup() Li Zefan
     [not found] ` <48B21756.4020208-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2008-08-25 16:43   ` Serge E. Hallyn
2008-08-25 16:43 ` Serge E. Hallyn
  -- strict thread matches above, loose matches on Subject: below --
2008-08-25  2:22 Li Zefan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.