netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] net: iucv: Free memory obtained by kzalloc
@ 2018-03-01  5:25 Arvind Yadav
  2018-03-01  9:45 ` Ursula Braun
  0 siblings, 1 reply; 2+ messages in thread
From: Arvind Yadav @ 2018-03-01  5:25 UTC (permalink / raw)
  To: jwi, ubraun, davem; +Cc: linux-kernel, linux-s390, netdev

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] net: iucv: Free memory obtained by kzalloc
  2018-03-01  5:25 [PATCH v2] net: iucv: Free memory obtained by kzalloc Arvind Yadav
@ 2018-03-01  9:45 ` Ursula Braun
  0 siblings, 0 replies; 2+ messages in thread
From: Ursula Braun @ 2018-03-01  9:45 UTC (permalink / raw)
  To: Arvind Yadav; +Cc: jwi, davem, linux-kernel, linux-s390, netdev



On 03/01/2018 06:25 AM, Arvind Yadav wrote:
> 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:
>

Just put_device() should be sufficient here; please get rid of the kfree() call.
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-03-01  9:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-01  5:25 [PATCH v2] net: iucv: Free memory obtained by kzalloc Arvind Yadav
2018-03-01  9:45 ` Ursula Braun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).