[PATCH 08/10] staging/irda/net: Use common error handling code in irias_new_object()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 12 Oct 2017 08:52:53 +0200

Add a jump target so that a bit of exception handling can be better
reused at the end of this function.

Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
---
 drivers/staging/irda/net/irias_object.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/irda/net/irias_object.c b/drivers/staging/irda/net/irias_object.c
index 4c2c65e28836..0c89800d597d 100644
--- a/drivers/staging/irda/net/irias_object.c
+++ b/drivers/staging/irda/net/irias_object.c
@@ -54,10 +54,9 @@ struct ias_object *irias_new_object( char *name, int id)
 
 	obj->magic = IAS_OBJECT_MAGIC;
 	obj->name = kstrndup(name, IAS_MAX_CLASSNAME, GFP_ATOMIC);
-	if (!obj->name) {
-		kfree(obj);
-		return NULL;
-	}
+	if (!obj->name)
+		goto free_object;
+
 	obj->id = id;
 
 	/* Locking notes : the attrib spinlock has lower precendence
@@ -68,11 +67,14 @@ struct ias_object *irias_new_object( char *name, int id)
 		net_warn_ratelimited("%s(), Unable to allocate attribs!\n",
 				     __func__);
 		kfree(obj->name);
-		kfree(obj);
-		return NULL;
+		goto free_object;
 	}
 
 	return obj;
+
+free_object:
+	kfree(obj);
+	return NULL;
 }
 EXPORT_SYMBOL(irias_new_object);
 
-- 
2.14.2

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux