From mboxrd@z Thu Jan 1 00:00:00 1970 From: aris-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org Subject: [PATCH v4 7/9] devcg: split single exception copy from dev_exceptions_copy() Date: Wed, 30 Jan 2013 12:11:08 -0500 Message-ID: <20130130171102.108794435@napanee.usersys.redhat.com> References: <20130130171101.060853036@napanee.usersys.redhat.com> Return-path: Content-Disposition: inline; filename=exceptions_copy.patch Sender: cgroups-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Cc: cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Tejun Heo , Serge Hallyn This patch is in preparation for hierarchy support This patch doesn't introduce any functional changes. Acked-by: Tejun Heo Cc: Tejun Heo Cc: Serge Hallyn Signed-off-by: Aristeu Rozanski --- security/device_cgroup.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) --- github.orig/security/device_cgroup.c 2013-01-29 11:49:16.076677425 -0500 +++ github/security/device_cgroup.c 2013-01-29 11:49:16.374681863 -0500 @@ -89,20 +89,30 @@ static int devcgroup_can_attach(struct c return 0; } +static int dev_exception_copy(struct list_head *dest, + struct dev_exception_item *ex) +{ + struct dev_exception_item *new; + + new = kmemdup(ex, sizeof(*ex), GFP_KERNEL); + if (!new) + return -ENOMEM; + list_add_tail(&new->list, dest); + return 0; +} + /* * called under devcgroup_mutex */ static int dev_exceptions_copy(struct list_head *dest, struct list_head *orig) { - struct dev_exception_item *ex, *tmp, *new; + struct dev_exception_item *ex, *tmp; lockdep_assert_held(&devcgroup_mutex); list_for_each_entry(ex, orig, list) { - new = kmemdup(ex, sizeof(*ex), GFP_KERNEL); - if (!new) + if (dev_exception_copy(dest, ex)) goto free_and_exit; - list_add_tail(&new->list, dest); } return 0;