public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Remove unnecessary devm_kfree
@ 2021-01-11 22:32 Bean Huo
  2021-01-11 22:32 ` [PATCH 1/2] scsi: hisi_sas: " Bean Huo
  2021-01-11 22:32 ` [PATCH 2/2] scsi: ufs: " Bean Huo
  0 siblings, 2 replies; 4+ messages in thread
From: Bean Huo @ 2021-01-11 22:32 UTC (permalink / raw)
  To: alim.akhtar, avri.altman, john.garry, jejb, martin.petersen,
	ebiggers, satyat, shipujin.t
  Cc: linux-scsi, linux-kernel, Bean Huo

From: Bean Huo <beanhuo@micron.com>

*** BLURB HERE ***

Bean Huo (2):
  scsi: hisi_sas: Remove unnecessary devm_kfree
  scsi: ufs: Remove unnecessary devm_kfree

 drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 26 --------------------------
 drivers/scsi/ufs/ufshcd-crypto.c       |  4 +---
 2 files changed, 1 insertion(+), 29 deletions(-)

-- 
2.17.1


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

* [PATCH 1/2] scsi: hisi_sas: Remove unnecessary devm_kfree
  2021-01-11 22:32 [PATCH 0/2] Remove unnecessary devm_kfree Bean Huo
@ 2021-01-11 22:32 ` Bean Huo
  2021-01-11 22:32 ` [PATCH 2/2] scsi: ufs: " Bean Huo
  1 sibling, 0 replies; 4+ messages in thread
From: Bean Huo @ 2021-01-11 22:32 UTC (permalink / raw)
  To: alim.akhtar, avri.altman, john.garry, jejb, martin.petersen,
	ebiggers, satyat, shipujin.t
  Cc: linux-scsi, linux-kernel, Bean Huo

From: Bean Huo <beanhuo@micron.com>

The memory allocated with devm_kzalloc() is freed automatically
no need to explicitly call devm_kfree.

Signed-off-by: Bean Huo <beanhuo@micron.com>
---
 drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 26 --------------------------
 1 file changed, 26 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
index 91a7286e8102..9e590f5f1a6b 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
@@ -4172,30 +4172,6 @@ static void debugfs_work_handler_v3_hw(struct work_struct *work)
 	hisi_hba->debugfs_dump_index++;
 }
 
-static void debugfs_release_v3_hw(struct hisi_hba *hisi_hba, int dump_index)
-{
-	struct device *dev = hisi_hba->dev;
-	int i;
-
-	devm_kfree(dev, hisi_hba->debugfs_iost_cache[dump_index].cache);
-	devm_kfree(dev, hisi_hba->debugfs_itct_cache[dump_index].cache);
-	devm_kfree(dev, hisi_hba->debugfs_iost[dump_index].iost);
-	devm_kfree(dev, hisi_hba->debugfs_itct[dump_index].itct);
-
-	for (i = 0; i < hisi_hba->queue_count; i++)
-		devm_kfree(dev, hisi_hba->debugfs_dq[dump_index][i].hdr);
-
-	for (i = 0; i < hisi_hba->queue_count; i++)
-		devm_kfree(dev,
-			   hisi_hba->debugfs_cq[dump_index][i].complete_hdr);
-
-	for (i = 0; i < DEBUGFS_REGS_NUM; i++)
-		devm_kfree(dev, hisi_hba->debugfs_regs[dump_index][i].data);
-
-	for (i = 0; i < hisi_hba->n_phy; i++)
-		devm_kfree(dev, hisi_hba->debugfs_port_reg[dump_index][i].data);
-}
-
 static const struct hisi_sas_debugfs_reg *debugfs_reg_array_v3_hw[DEBUGFS_REGS_NUM] = {
 	[DEBUGFS_GLOBAL] = &debugfs_global_reg,
 	[DEBUGFS_AXI] = &debugfs_axi_reg,
@@ -4286,8 +4262,6 @@ static int debugfs_alloc_v3_hw(struct hisi_hba *hisi_hba, int dump_index)
 
 	return 0;
 fail:
-	for (i = 0; i < hisi_sas_debugfs_dump_count; i++)
-		debugfs_release_v3_hw(hisi_hba, i);
 	return -ENOMEM;
 }
 
-- 
2.17.1


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

* [PATCH 2/2] scsi: ufs: Remove unnecessary devm_kfree
  2021-01-11 22:32 [PATCH 0/2] Remove unnecessary devm_kfree Bean Huo
  2021-01-11 22:32 ` [PATCH 1/2] scsi: hisi_sas: " Bean Huo
@ 2021-01-11 22:32 ` Bean Huo
  2021-01-11 22:45   ` Eric Biggers
  1 sibling, 1 reply; 4+ messages in thread
From: Bean Huo @ 2021-01-11 22:32 UTC (permalink / raw)
  To: alim.akhtar, avri.altman, john.garry, jejb, martin.petersen,
	ebiggers, satyat, shipujin.t
  Cc: linux-scsi, linux-kernel, Bean Huo

From: Bean Huo <beanhuo@micron.com>

The memory allocated with devm_kzalloc() is freed automatically
no need to explicitly call devm_kfree.

Signed-off-by: Bean Huo <beanhuo@micron.com>
---
 drivers/scsi/ufs/ufshcd-crypto.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd-crypto.c b/drivers/scsi/ufs/ufshcd-crypto.c
index 07310b12a5dc..ec80ec83cf85 100644
--- a/drivers/scsi/ufs/ufshcd-crypto.c
+++ b/drivers/scsi/ufs/ufshcd-crypto.c
@@ -182,7 +182,7 @@ int ufshcd_hba_init_crypto_capabilities(struct ufs_hba *hba)
 	err = blk_ksm_init(&hba->ksm,
 			   hba->crypto_capabilities.config_count + 1);
 	if (err)
-		goto out_free_caps;
+		goto out;
 
 	hba->ksm.ksm_ll_ops = ufshcd_ksm_ops;
 	/* UFS only supports 8 bytes for any DUN */
@@ -208,8 +208,6 @@ int ufshcd_hba_init_crypto_capabilities(struct ufs_hba *hba)
 
 	return 0;
 
-out_free_caps:
-	devm_kfree(hba->dev, hba->crypto_cap_array);
 out:
 	/* Indicate that init failed by clearing UFSHCD_CAP_CRYPTO */
 	hba->caps &= ~UFSHCD_CAP_CRYPTO;
-- 
2.17.1


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

* Re: [PATCH 2/2] scsi: ufs: Remove unnecessary devm_kfree
  2021-01-11 22:32 ` [PATCH 2/2] scsi: ufs: " Bean Huo
@ 2021-01-11 22:45   ` Eric Biggers
  0 siblings, 0 replies; 4+ messages in thread
From: Eric Biggers @ 2021-01-11 22:45 UTC (permalink / raw)
  To: Bean Huo
  Cc: alim.akhtar, avri.altman, john.garry, jejb, martin.petersen,
	satyat, shipujin.t, linux-scsi, linux-kernel, Bean Huo

On Mon, Jan 11, 2021 at 11:32:02PM +0100, Bean Huo wrote:
> From: Bean Huo <beanhuo@micron.com>
> 
> The memory allocated with devm_kzalloc() is freed automatically
> no need to explicitly call devm_kfree.
> 
> Signed-off-by: Bean Huo <beanhuo@micron.com>
> ---
>  drivers/scsi/ufs/ufshcd-crypto.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufshcd-crypto.c b/drivers/scsi/ufs/ufshcd-crypto.c
> index 07310b12a5dc..ec80ec83cf85 100644
> --- a/drivers/scsi/ufs/ufshcd-crypto.c
> +++ b/drivers/scsi/ufs/ufshcd-crypto.c
> @@ -182,7 +182,7 @@ int ufshcd_hba_init_crypto_capabilities(struct ufs_hba *hba)
>  	err = blk_ksm_init(&hba->ksm,
>  			   hba->crypto_capabilities.config_count + 1);
>  	if (err)
> -		goto out_free_caps;
> +		goto out;
>  
>  	hba->ksm.ksm_ll_ops = ufshcd_ksm_ops;
>  	/* UFS only supports 8 bytes for any DUN */
> @@ -208,8 +208,6 @@ int ufshcd_hba_init_crypto_capabilities(struct ufs_hba *hba)
>  
>  	return 0;
>  
> -out_free_caps:
> -	devm_kfree(hba->dev, hba->crypto_cap_array);
>  out:
>  	/* Indicate that init failed by clearing UFSHCD_CAP_CRYPTO */
>  	hba->caps &= ~UFSHCD_CAP_CRYPTO;

Looks fine, feel free to add:

	Reviewed-by: Eric Biggers <ebiggers@google.com>

I think this was here to free the memory in the case where the crypto support
gets disabled but the UFS host initialization still continues, so that the space
wouldn't be wasted.  But that's not what happens, as this is only reached on
ENOMEM which is a fatal error.

- Eric

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

end of thread, other threads:[~2021-01-12  0:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-11 22:32 [PATCH 0/2] Remove unnecessary devm_kfree Bean Huo
2021-01-11 22:32 ` [PATCH 1/2] scsi: hisi_sas: " Bean Huo
2021-01-11 22:32 ` [PATCH 2/2] scsi: ufs: " Bean Huo
2021-01-11 22:45   ` Eric Biggers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox