[net,1/1] net/iucv: Free memory obtained by kzalloc

Message ID 20180313155006.88162-2-jwi@linux.vnet.ibm.com
State Accepted
Delegated to: David Miller
Headers show
Series
  • net/iucv: fix 2018-03-13
Related show

Commit Message

Julian Wiedmann March 13, 2018, 3:50 p.m.
From: Arvind Yadav <arvind.yadav.cs@gmail.com>

Free memory by calling put_device(), if afiucv_iucv_init is not
successful.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Ursula Braun <ursula.braun@de.ibm.com>
Signed-off-by: Julian Wiedmann <jwi@linux.vnet.ibm.com>
---
 net/iucv/af_iucv.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

David Miller March 16, 2018, 3:44 p.m. | #1
From: Julian Wiedmann <jwi@linux.vnet.ibm.com>
Date: Tue, 13 Mar 2018 16:50:06 +0100

> From: Arvind Yadav <arvind.yadav.cs@gmail.com>
> 
> Free memory by calling put_device(), if afiucv_iucv_init is not
> successful.
> 
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
> Reviewed-by: Cornelia Huck <cohuck@redhat.com>
> Signed-off-by: Ursula Braun <ursula.braun@de.ibm.com>
> Signed-off-by: Julian Wiedmann <jwi@linux.vnet.ibm.com>

Applied, thank you.

Patch

diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
index 1e8cc7bcbca3..9e2643ab4ccb 100644
--- a/net/iucv/af_iucv.c
+++ b/net/iucv/af_iucv.c
@@ -2433,9 +2433,11 @@  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);
 out_driver:
 	driver_unregister(&af_iucv_driver);
 out_iucv: