* [PATCH] scsi: scsi_transport_iscsi: use put_device() instead of kfree()
@ 2018-03-07 11:37 ` Arvind Yadav
0 siblings, 0 replies; 8+ messages in thread
From: Arvind Yadav @ 2018-03-07 11:37 UTC (permalink / raw)
To: lduncan, cleech, jejb, martin.petersen
Cc: linux-kernel, open-iscsi, linux-scsi
Never directly free @dev after calling device_register(), even
if it returned an error! Always use put_device() to give up the
reference initialized.
Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
drivers/scsi/scsi_transport_iscsi.c | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index f4b52b4..aacb7ab 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -221,8 +221,10 @@ struct iscsi_endpoint *
ep->dev.class = &iscsi_endpoint_class;
dev_set_name(&ep->dev, "ep-%llu", (unsigned long long) id);
err = device_register(&ep->dev);
- if (err)
- goto free_ep;
+ if (err) {
+ put_device(&ep->dev);
+ return NULL;
+ }
err = sysfs_create_group(&ep->dev.kobj, &iscsi_endpoint_group);
if (err)
@@ -235,10 +237,6 @@ struct iscsi_endpoint *
unregister_dev:
device_unregister(&ep->dev);
return NULL;
-
-free_ep:
- kfree(ep);
- return NULL;
}
EXPORT_SYMBOL_GPL(iscsi_create_endpoint);
@@ -783,7 +781,7 @@ struct iscsi_iface *
free_iface:
put_device(iface->dev.parent);
- kfree(iface);
+ put_device(&iface->dev);
return NULL;
}
EXPORT_SYMBOL_GPL(iscsi_create_iface);
@@ -1260,7 +1258,7 @@ struct iscsi_bus_flash_session *
return fnode_sess;
free_fnode_sess:
- kfree(fnode_sess);
+ put_device(&fnode_sess->dev);
return NULL;
}
EXPORT_SYMBOL_GPL(iscsi_create_flashnode_sess);
@@ -1308,7 +1306,7 @@ struct iscsi_bus_flash_conn *
return fnode_conn;
free_fnode_conn:
- kfree(fnode_conn);
+ put_device(&fnode_conn->dev);
return NULL;
}
EXPORT_SYMBOL_GPL(iscsi_create_flashnode_conn);
@@ -2268,6 +2266,8 @@ struct iscsi_cls_conn *
release_parent_ref:
put_device(&session->dev);
+ put_device(&conn->dev);
+ conn = NULL;
free_conn:
kfree(conn);
return NULL;
@@ -4420,8 +4420,10 @@ struct scsi_transport_template *
priv->dev.class = &iscsi_transport_class;
dev_set_name(&priv->dev, "%s", tt->name);
err = device_register(&priv->dev);
- if (err)
- goto free_priv;
+ if (err) {
+ put_device(&priv->dev);
+ return NULL;
+ }
err = sysfs_create_group(&priv->dev.kobj, &iscsi_transport_group);
if (err)
@@ -4456,9 +4458,6 @@ struct scsi_transport_template *
unregister_dev:
device_unregister(&priv->dev);
return NULL;
-free_priv:
- kfree(priv);
- return NULL;
}
EXPORT_SYMBOL_GPL(iscsi_register_transport);
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH] scsi: scsi_transport_iscsi: use put_device() instead of kfree()
@ 2018-03-07 11:37 ` Arvind Yadav
0 siblings, 0 replies; 8+ messages in thread
From: Arvind Yadav @ 2018-03-07 11:37 UTC (permalink / raw)
To: lduncan-IBi9RG/b67k, cleech-H+wXaHxf7aLQT0dZR+AlfA,
jejb-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8,
martin.petersen-QHcLZuEGTsvQT0dZR+AlfA
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
open-iscsi-/JYPxA39Uh5TLH3MbocFFw,
linux-scsi-u79uwXL29TY76Z2rM5mHXA
Never directly free @dev after calling device_register(), even
if it returned an error! Always use put_device() to give up the
reference initialized.
Signed-off-by: Arvind Yadav <arvind.yadav.cs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
drivers/scsi/scsi_transport_iscsi.c | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index f4b52b4..aacb7ab 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -221,8 +221,10 @@ struct iscsi_endpoint *
ep->dev.class = &iscsi_endpoint_class;
dev_set_name(&ep->dev, "ep-%llu", (unsigned long long) id);
err = device_register(&ep->dev);
- if (err)
- goto free_ep;
+ if (err) {
+ put_device(&ep->dev);
+ return NULL;
+ }
err = sysfs_create_group(&ep->dev.kobj, &iscsi_endpoint_group);
if (err)
@@ -235,10 +237,6 @@ struct iscsi_endpoint *
unregister_dev:
device_unregister(&ep->dev);
return NULL;
-
-free_ep:
- kfree(ep);
- return NULL;
}
EXPORT_SYMBOL_GPL(iscsi_create_endpoint);
@@ -783,7 +781,7 @@ struct iscsi_iface *
free_iface:
put_device(iface->dev.parent);
- kfree(iface);
+ put_device(&iface->dev);
return NULL;
}
EXPORT_SYMBOL_GPL(iscsi_create_iface);
@@ -1260,7 +1258,7 @@ struct iscsi_bus_flash_session *
return fnode_sess;
free_fnode_sess:
- kfree(fnode_sess);
+ put_device(&fnode_sess->dev);
return NULL;
}
EXPORT_SYMBOL_GPL(iscsi_create_flashnode_sess);
@@ -1308,7 +1306,7 @@ struct iscsi_bus_flash_conn *
return fnode_conn;
free_fnode_conn:
- kfree(fnode_conn);
+ put_device(&fnode_conn->dev);
return NULL;
}
EXPORT_SYMBOL_GPL(iscsi_create_flashnode_conn);
@@ -2268,6 +2266,8 @@ struct iscsi_cls_conn *
release_parent_ref:
put_device(&session->dev);
+ put_device(&conn->dev);
+ conn = NULL;
free_conn:
kfree(conn);
return NULL;
@@ -4420,8 +4420,10 @@ struct scsi_transport_template *
priv->dev.class = &iscsi_transport_class;
dev_set_name(&priv->dev, "%s", tt->name);
err = device_register(&priv->dev);
- if (err)
- goto free_priv;
+ if (err) {
+ put_device(&priv->dev);
+ return NULL;
+ }
err = sysfs_create_group(&priv->dev.kobj, &iscsi_transport_group);
if (err)
@@ -4456,9 +4458,6 @@ struct scsi_transport_template *
unregister_dev:
device_unregister(&priv->dev);
return NULL;
-free_priv:
- kfree(priv);
- return NULL;
}
EXPORT_SYMBOL_GPL(iscsi_register_transport);
--
1.9.1
--
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
Visit this group at https://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] scsi: scsi_transport_iscsi: use put_device() instead of kfree()
@ 2018-03-15 4:11 ` Martin K. Petersen
0 siblings, 0 replies; 8+ messages in thread
From: Martin K. Petersen @ 2018-03-15 4:11 UTC (permalink / raw)
To: lduncan, cleech
Cc: Arvind Yadav, jejb, martin.petersen, linux-kernel, open-iscsi,
linux-scsi
> Never directly free @dev after calling device_register(), even
> if it returned an error! Always use put_device() to give up the
> reference initialized.
Lee, Chris: Please review!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] scsi: scsi_transport_iscsi: use put_device() instead of kfree()
@ 2018-03-15 4:11 ` Martin K. Petersen
0 siblings, 0 replies; 8+ messages in thread
From: Martin K. Petersen @ 2018-03-15 4:11 UTC (permalink / raw)
To: lduncan-IBi9RG/b67k, cleech-H+wXaHxf7aLQT0dZR+AlfA
Cc: Arvind Yadav, jejb-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8,
martin.petersen-QHcLZuEGTsvQT0dZR+AlfA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
open-iscsi-/JYPxA39Uh5TLH3MbocFFw,
linux-scsi-u79uwXL29TY76Z2rM5mHXA
> Never directly free @dev after calling device_register(), even
> if it returned an error! Always use put_device() to give up the
> reference initialized.
Lee, Chris: Please review!
--
Martin K. Petersen Oracle Linux Engineering
--
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
Visit this group at https://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] scsi: scsi_transport_iscsi: use put_device() instead of kfree()
@ 2018-03-15 17:44 ` Chris Leech
0 siblings, 0 replies; 8+ messages in thread
From: Chris Leech @ 2018-03-15 17:44 UTC (permalink / raw)
To: Arvind Yadav
Cc: lduncan, jejb, martin.petersen, linux-kernel, open-iscsi, linux-scsi
On Wed, Mar 07, 2018 at 05:07:33PM +0530, Arvind Yadav wrote:
> Never directly free @dev after calling device_register(), even
> if it returned an error! Always use put_device() to give up the
> reference initialized.
>
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
> ---
> drivers/scsi/scsi_transport_iscsi.c | 27 +++++++++++++--------------
> 1 file changed, 13 insertions(+), 14 deletions(-)
>
> @@ -783,7 +781,7 @@ struct iscsi_iface *
>
> free_iface:
> put_device(iface->dev.parent);
> - kfree(iface);
> + put_device(&iface->dev);
> return NULL;
> }
> EXPORT_SYMBOL_GPL(iscsi_create_iface);
Am I reading the device code correctly that the parent reference is only
released in the unregister path (device_unregister calls device_del) and
so the manual put_device on the parent here is still correct?
Just want to make sure that's still needed with the call to put_device.
Other than that question, I this all looks good.
Thanks.
Signed-off-by: Chris Leech <cleech@redhat.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] scsi: scsi_transport_iscsi: use put_device() instead of kfree()
@ 2018-03-15 17:44 ` Chris Leech
0 siblings, 0 replies; 8+ messages in thread
From: Chris Leech @ 2018-03-15 17:44 UTC (permalink / raw)
To: Arvind Yadav
Cc: lduncan-IBi9RG/b67k, jejb-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8,
martin.petersen-QHcLZuEGTsvQT0dZR+AlfA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
open-iscsi-/JYPxA39Uh5TLH3MbocFFw,
linux-scsi-u79uwXL29TY76Z2rM5mHXA
On Wed, Mar 07, 2018 at 05:07:33PM +0530, Arvind Yadav wrote:
> Never directly free @dev after calling device_register(), even
> if it returned an error! Always use put_device() to give up the
> reference initialized.
>
> Signed-off-by: Arvind Yadav <arvind.yadav.cs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
> drivers/scsi/scsi_transport_iscsi.c | 27 +++++++++++++--------------
> 1 file changed, 13 insertions(+), 14 deletions(-)
>
> @@ -783,7 +781,7 @@ struct iscsi_iface *
>
> free_iface:
> put_device(iface->dev.parent);
> - kfree(iface);
> + put_device(&iface->dev);
> return NULL;
> }
> EXPORT_SYMBOL_GPL(iscsi_create_iface);
Am I reading the device code correctly that the parent reference is only
released in the unregister path (device_unregister calls device_del) and
so the manual put_device on the parent here is still correct?
Just want to make sure that's still needed with the call to put_device.
Other than that question, I this all looks good.
Thanks.
Signed-off-by: Chris Leech <cleech-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
--
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
Visit this group at https://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] scsi: scsi_transport_iscsi: use put_device() instead of kfree()
@ 2018-03-17 9:37 ` arvindY
0 siblings, 0 replies; 8+ messages in thread
From: arvindY @ 2018-03-17 9:37 UTC (permalink / raw)
To: Chris Leech, lduncan, jejb, martin.petersen, linux-kernel,
open-iscsi, linux-scsi
On Thursday 15 March 2018 11:14 PM, Chris Leech wrote:
> On Wed, Mar 07, 2018 at 05:07:33PM +0530, Arvind Yadav wrote:
>> Never directly free @dev after calling device_register(), even
>> if it returned an error! Always use put_device() to give up the
>> reference initialized.
>>
>> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
>> ---
>> drivers/scsi/scsi_transport_iscsi.c | 27 +++++++++++++--------------
>> 1 file changed, 13 insertions(+), 14 deletions(-)
>>
>> @@ -783,7 +781,7 @@ struct iscsi_iface *
>>
>> free_iface:
>> put_device(iface->dev.parent);
>> - kfree(iface);
>> + put_device(&iface->dev);
>> return NULL;
>> }
>> EXPORT_SYMBOL_GPL(iscsi_create_iface);
> Am I reading the device code correctly that the parent reference is only
> released in the unregister path (device_unregister calls device_del) and
> so the manual put_device on the parent here is still correct?
>
> Just want to make sure that's still needed with the call to put_device.
The manual put_device on the parent is not correct.
This should be removed for here. we should call
put_device(&iface->dev) only and It'll released
parent reference.
> Other than that question, I this all looks good.
> Thanks.
>
> Signed-off-by: Chris Leech <cleech@redhat.com>
>
~arvind
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] scsi: scsi_transport_iscsi: use put_device() instead of kfree()
@ 2018-03-17 9:37 ` arvindY
0 siblings, 0 replies; 8+ messages in thread
From: arvindY @ 2018-03-17 9:37 UTC (permalink / raw)
To: Chris Leech, lduncan-IBi9RG/b67k,
jejb-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8,
martin.petersen-QHcLZuEGTsvQT0dZR+AlfA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
open-iscsi-/JYPxA39Uh5TLH3MbocFFw,
linux-scsi-u79uwXL29TY76Z2rM5mHXA
On Thursday 15 March 2018 11:14 PM, Chris Leech wrote:
> On Wed, Mar 07, 2018 at 05:07:33PM +0530, Arvind Yadav wrote:
>> Never directly free @dev after calling device_register(), even
>> if it returned an error! Always use put_device() to give up the
>> reference initialized.
>>
>> Signed-off-by: Arvind Yadav <arvind.yadav.cs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>> ---
>> drivers/scsi/scsi_transport_iscsi.c | 27 +++++++++++++--------------
>> 1 file changed, 13 insertions(+), 14 deletions(-)
>>
>> @@ -783,7 +781,7 @@ struct iscsi_iface *
>>
>> free_iface:
>> put_device(iface->dev.parent);
>> - kfree(iface);
>> + put_device(&iface->dev);
>> return NULL;
>> }
>> EXPORT_SYMBOL_GPL(iscsi_create_iface);
> Am I reading the device code correctly that the parent reference is only
> released in the unregister path (device_unregister calls device_del) and
> so the manual put_device on the parent here is still correct?
>
> Just want to make sure that's still needed with the call to put_device.
The manual put_device on the parent is not correct.
This should be removed for here. we should call
put_device(&iface->dev) only and It'll released
parent reference.
> Other than that question, I this all looks good.
> Thanks.
>
> Signed-off-by: Chris Leech <cleech-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>
~arvind
--
You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
Visit this group at https://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2018-03-17 9:38 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-07 11:37 [PATCH] scsi: scsi_transport_iscsi: use put_device() instead of kfree() Arvind Yadav
2018-03-07 11:37 ` Arvind Yadav
2018-03-15 4:11 ` Martin K. Petersen
2018-03-15 4:11 ` Martin K. Petersen
2018-03-15 17:44 ` Chris Leech
2018-03-15 17:44 ` Chris Leech
2018-03-17 9:37 ` arvindY
2018-03-17 9:37 ` arvindY
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.