diff mbox series

[-next] scsi: target/core: Use kmem_cache_free() instead of kfree()

Message ID 1545049193-159337-1-git-send-email-weiyongjun1@huawei.com (mailing list archive)
State Accepted
Commit 8b2db98e814a5ec45e8800fc22ca9000ae0a517b
Headers show
Series [-next] scsi: target/core: Use kmem_cache_free() instead of kfree() | expand

Commit Message

weiyongjun (A) Dec. 17, 2018, 12:19 p.m. UTC
memory allocated by kmem_cache_alloc() should be freed using
kmem_cache_free(), not kfree().

Fixes: ad669505c4e9 ("scsi: target/core: Make sure that target_wait_for_sess_cmds() waits long enough")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/target/target_core_transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Bart Van Assche Dec. 17, 2018, 4:16 p.m. UTC | #1
On Mon, 2018-12-17 at 12:19 +0000, Wei Yongjun wrote:
> memory allocated by kmem_cache_alloc() should be freed using
> kmem_cache_free(), not kfree().
> 
> Fixes: ad669505c4e9 ("scsi: target/core: Make sure that target_wait_for_sess_cmds() waits long enough")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> ---
>  drivers/target/target_core_transport.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
> index 65a1819..ef9e75b 100644
> --- a/drivers/target/target_core_transport.c
> +++ b/drivers/target/target_core_transport.c
> @@ -266,7 +266,7 @@ struct se_session *transport_alloc_session(enum target_prot_op sup_prot_ops)
>  	}
>  	ret = transport_init_session(se_sess);
>  	if (ret < 0) {
> -		kfree(se_sess);
> +		kmem_cache_free(se_sess_cache, se_sess);
>  		return ERR_PTR(ret);
>  	}
>  	se_sess->sup_prot_ops = sup_prot_ops;

Thanks for this patch.

Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Martin K. Petersen Dec. 19, 2018, 3:53 a.m. UTC | #2
Wei,

> memory allocated by kmem_cache_alloc() should be freed using
> kmem_cache_free(), not kfree().

Applied to 4.21/scsi-queue, thanks!
diff mbox series

Patch

diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 65a1819..ef9e75b 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -266,7 +266,7 @@  struct se_session *transport_alloc_session(enum target_prot_op sup_prot_ops)
 	}
 	ret = transport_init_session(se_sess);
 	if (ret < 0) {
-		kfree(se_sess);
+		kmem_cache_free(se_sess_cache, se_sess);
 		return ERR_PTR(ret);
 	}
 	se_sess->sup_prot_ops = sup_prot_ops;