From d656d032532465340b540b9f9137b409446f18da Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Mon, 20 Oct 2014 17:28:55 +0200 Subject: [PATCH] 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 --- handle.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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; -- 2.34.1