target:fix destory device in target_configure_device
diff mbox

Message ID 1516018177-7714-1-git-send-email-tang.wenji@zte.com.cn
State New, archived
Headers show

Commit Message

tang.wenji@zte.com.cn Jan. 15, 2018, 12:09 p.m. UTC
From: tangwenji <tang.wenji@zte.com.cn>

After dev->transport->configure_device succeeds,target_configure_device
exits abnormally, dev_flags has not set DF_CONFIGURED yet, does not call
destory_device function in free_device

Signed-off-by: tangwenji <tang.wenji@zte.com.cn>
---
 drivers/target/target_core_device.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Mike Christie Jan. 15, 2018, 8:43 p.m. UTC | #1
On 01/15/2018 06:09 AM, tang.wenji@zte.com.cn wrote:
> From: tangwenji <tang.wenji@zte.com.cn>
> 
> After dev->transport->configure_device succeeds,target_configure_device
> exits abnormally, dev_flags has not set DF_CONFIGURED yet, does not call
> destory_device function in free_device
> 
> Signed-off-by: tangwenji <tang.wenji@zte.com.cn>
> ---
>  drivers/target/target_core_device.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
> index e8dd6da..18716fa 100644
> --- a/drivers/target/target_core_device.c
> +++ b/drivers/target/target_core_device.c
> @@ -997,7 +997,7 @@ int target_configure_device(struct se_device *dev)
>  
>  	ret = core_setup_alua(dev);
>  	if (ret)
> -		goto out_free_index;
> +		goto out_destory_device;
>  
>  	/*
>  	 * Startup the struct se_device processing thread
> @@ -1041,6 +1041,8 @@ int target_configure_device(struct se_device *dev)
>  
>  out_free_alua:
>  	core_alua_free_lu_gp_mem(dev);
> +out_destory_device:
> +	dev->transport->destroy_device(dev);
>  out_free_index:
>  	mutex_lock(&device_mutex);
>  	idr_remove(&devices_idr, dev->dev_index);
> 

Looks ok to me.

Reviewed-by: Mike Christie <mchristi@redhat.com>
--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Bart Van Assche Jan. 16, 2018, 4:04 p.m. UTC | #2
On Mon, 2018-01-15 at 20:09 +0800, tang.wenji@zte.com.cn wrote:
>  	if (ret)

> -		goto out_free_index;

> +		goto out_destory_device;


Hello Tang,

Please fix the spelling of "destroy".

Thanks,

Bart.
Nicholas A. Bellinger Jan. 18, 2018, 9:22 a.m. UTC | #3
On Mon, 2018-01-15 at 14:43 -0600, Mike Christie wrote:
> On 01/15/2018 06:09 AM, tang.wenji@zte.com.cn wrote:
> > From: tangwenji <tang.wenji@zte.com.cn>
> > 
> > After dev->transport->configure_device succeeds,target_configure_device
> > exits abnormally, dev_flags has not set DF_CONFIGURED yet, does not call
> > destory_device function in free_device
> > 
> > Signed-off-by: tangwenji <tang.wenji@zte.com.cn>
> > ---
> >  drivers/target/target_core_device.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 

Applied.  Thanks Tang + MNC.

--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index e8dd6da..18716fa 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -997,7 +997,7 @@  int target_configure_device(struct se_device *dev)
 
 	ret = core_setup_alua(dev);
 	if (ret)
-		goto out_free_index;
+		goto out_destory_device;
 
 	/*
 	 * Startup the struct se_device processing thread
@@ -1041,6 +1041,8 @@  int target_configure_device(struct se_device *dev)
 
 out_free_alua:
 	core_alua_free_lu_gp_mem(dev);
+out_destory_device:
+	dev->transport->destroy_device(dev);
 out_free_index:
 	mutex_lock(&device_mutex);
 	idr_remove(&devices_idr, dev->dev_index);