lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <X/zU7uWK5s22th4B@sol.localdomain>
Date:   Mon, 11 Jan 2021 14:45:02 -0800
From:   Eric Biggers <ebiggers@...nel.org>
To:     Bean Huo <huobean@...il.com>
Cc:     alim.akhtar@...sung.com, avri.altman@....com,
        john.garry@...wei.com, jejb@...ux.ibm.com,
        martin.petersen@...cle.com, satyat@...gle.com,
        shipujin.t@...il.com, linux-scsi@...r.kernel.org,
        linux-kernel@...r.kernel.org, Bean Huo <beanhuo@...ron.com>
Subject: Re: [PATCH 2/2] scsi: ufs: Remove unnecessary devm_kfree

On Mon, Jan 11, 2021 at 11:32:02PM +0100, Bean Huo wrote:
> From: Bean Huo <beanhuo@...ron.com>
> 
> The memory allocated with devm_kzalloc() is freed automatically
> no need to explicitly call devm_kfree.
> 
> Signed-off-by: Bean Huo <beanhuo@...ron.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@...gle.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ