lkml.org 
[lkml]   [2018]   [Mar]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2] net: iucv: Free memory obtained by kzalloc
Date
Free memory, if afiucv_iucv_init is not successful. So calling
put_device() before kfree(). This will decrement the last reference.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
changes in v2:
Calling put_device() before kfree().

net/iucv/af_iucv.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
index 1e8cc7b..a07943f 100644
--- a/net/iucv/af_iucv.c
+++ b/net/iucv/af_iucv.c
@@ -2433,9 +2433,12 @@ static int afiucv_iucv_init(void)
af_iucv_dev->driver = &af_iucv_driver;
err = device_register(af_iucv_dev);
if (err)
- goto out_driver;
+ goto out_iucv_dev;
return 0;

+out_iucv_dev:
+ put_device(af_iucv_dev);
+ kfree(af_iucv_dev);
out_driver:
driver_unregister(&af_iucv_driver);
out_iucv:
--
1.9.1
\
 
 \ /
  Last update: 2018-03-01 06:29    [W:0.028 / U:0.296 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site