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] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZvDcEFXhpMo3K-Zd@google.com>
Date: Mon, 23 Sep 2024 03:10:08 +0000
From: Pranjal Shrivastava <praan@...gle.com>
To: Dipendra Khadka <kdipendra88@...il.com>
Cc: will@...nel.org, robin.murphy@....com, joro@...tes.org,
	baolu.lu@...ux.intel.com, linux-arm-kernel@...ts.infradead.org,
	iommu@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] Staging: iommu:  Replace null pointer check with IS_ERR
 in arm_smmu_domain_alloc_user()

On Sun, Sep 22, 2024 at 03:56:20PM +0000, Dipendra Khadka wrote:
> The smatch reported following:
> '''
> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c:3065 arm_smmu_domain_alloc_user() warn: 'smmu_domain' is an error pointer or valid
> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c:3068 arm_smmu_domain_alloc_user() error: 'smmu_domain' dereferencing possible ERR_PTR()
> '''
> 
> The function arm_smmu_domain_alloc() handles the null pointer after
> kzalloc and returns ERR_PTR(-ENOMEM).
> 
> Replacing condition check !smmu_domain with IS_ERR(smmu_domain) and
> returning smmu_domain.

Hi Dipendra,

Thanks for looking into the code. However, I think this was fixed last
month by Dan's patch [1] and has been merged in the master branch.
Please pull the latest. :)

[1]
 https://lore.kernel.org/linux-arm-kernel/172381875518.1794999.1134549433569030700.b4-ty@kernel.org/T/

> 
> Signed-off-by: Dipendra Khadka <kdipendra88@...il.com>
> ---
>  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> index a31460f9f3d4..19c53c6f7578 100644
> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> @@ -3062,8 +3062,8 @@ arm_smmu_domain_alloc_user(struct device *dev, u32 flags,
>  		return ERR_PTR(-EOPNOTSUPP);
>  
>  	smmu_domain = arm_smmu_domain_alloc();
> -	if (!smmu_domain)
> -		return ERR_PTR(-ENOMEM);
> +	if (IS_ERR(smmu_domain))
> +		return smmu_domain;

Quick note, using something like `ERR_CAST` is better in such cases.

>  
>  	smmu_domain->domain.type = IOMMU_DOMAIN_UNMANAGED;
>  	smmu_domain->domain.ops = arm_smmu_ops.default_domain_ops;
> -- 
> 2.43.0
> 
> 

Thanks,
Pranjal

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ