mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Bean Huo <huobean@gmail.com>
Cc: alim.akhtar@samsung.com, avri.altman@wdc.com,
	john.garry@huawei.com, jejb@linux.ibm.com,
	martin.petersen@oracle.com, satyat@google.com,
	shipujin.t@gmail.com, linux-scsi@vger.kernel.org,
	linux-kernel@vger.kernel.org, Bean Huo <beanhuo@micron.com>
Subject: Re: [PATCH 2/2] scsi: ufs: Remove unnecessary devm_kfree
Date: Mon, 11 Jan 2021 14:45:02 -0800	[thread overview]
Message-ID: <X/zU7uWK5s22th4B@sol.localdomain> (raw)
In-Reply-To: <20210111223202.26369-3-huobean@gmail.com>

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

      reply	other threads:[~2021-01-12  0:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-11 22:32 [PATCH 0/2] " 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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=X/zU7uWK5s22th4B@sol.localdomain \
    --to=ebiggers@kernel.org \
    --cc=alim.akhtar@samsung.com \
    --cc=avri.altman@wdc.com \
    --cc=beanhuo@micron.com \
    --cc=huobean@gmail.com \
    --cc=jejb@linux.ibm.com \
    --cc=john.garry@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=satyat@google.com \
    --cc=shipujin.t@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®