From: Daniel Mack Date: Mon, 20 Oct 2014 15:28:55 +0000 (+0200) Subject: handle: allocate handle after domain lookup X-Git-Tag: upstream/0.20141102.012929utc~74 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d656d032532465340b540b9f9137b409446f18da;p=platform%2Fcore%2Fsystem%2Fkdbus-bus.git handle: allocate handle after domain lookup Just a small cleanup that orders memory allocation after the domain has been looked up. That saves us an extra kfree() in the error path. Signed-off-by: Daniel Mack --- diff --git a/handle.c b/handle.c index 25e1cee..8ebf0df 100644 --- a/handle.c +++ b/handle.c @@ -98,16 +98,15 @@ static int kdbus_handle_open(struct inode *inode, struct file *file) struct kdbus_ep *ep; int ret; + /* find and reference domain */ + domain = kdbus_domain_find_by_major(MAJOR(inode->i_rdev)); + if (!domain || domain->disconnected) + return -ESHUTDOWN; + handle = kzalloc(sizeof(*handle), GFP_KERNEL); if (!handle) return -ENOMEM; - /* find and reference domain */ - domain = kdbus_domain_find_by_major(MAJOR(inode->i_rdev)); - if (!domain || domain->disconnected) { - kfree(handle); - return -ESHUTDOWN; - } handle->domain = domain; file->private_data = handle;