Re: [PATCH] iommu: add null pointer check

2022-04-28 Thread Joerg Roedel
On Tue, Mar 29, 2022 at 05:53:22AM +, cgel@gmail.com wrote:
> From: Lv Ruyi 
> 
> kmem_cache_zalloc is a memory allocation function which can return NULL
> when some internal memory errors happen. Add null pointer check to avoid
> dereferencing null pointer.
> 
> Reported-by: Zeal Robot 
> Signed-off-by: Lv Ruyi 
> ---
>  drivers/iommu/fsl_pamu_domain.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/iommu/fsl_pamu_domain.c b/drivers/iommu/fsl_pamu_domain.c
> index 69a4a62dc3b9..43849c027298 100644
> --- a/drivers/iommu/fsl_pamu_domain.c
> +++ b/drivers/iommu/fsl_pamu_domain.c
> @@ -152,6 +152,10 @@ static void attach_device(struct fsl_dma_domain 
> *dma_domain, int liodn, struct d
>   }
>  
>   info = kmem_cache_zalloc(iommu_devinfo_cache, GFP_ATOMIC);
> + if (!info) {
> + spin_unlock_irqrestore(_domain_lock, flags);
> + return;
> + }

Such errors need to be propagated.

___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


[PATCH] iommu: add null pointer check

2022-03-28 Thread cgel . zte
From: Lv Ruyi 

kmem_cache_zalloc is a memory allocation function which can return NULL
when some internal memory errors happen. Add null pointer check to avoid
dereferencing null pointer.

Reported-by: Zeal Robot 
Signed-off-by: Lv Ruyi 
---
 drivers/iommu/fsl_pamu_domain.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/iommu/fsl_pamu_domain.c b/drivers/iommu/fsl_pamu_domain.c
index 69a4a62dc3b9..43849c027298 100644
--- a/drivers/iommu/fsl_pamu_domain.c
+++ b/drivers/iommu/fsl_pamu_domain.c
@@ -152,6 +152,10 @@ static void attach_device(struct fsl_dma_domain 
*dma_domain, int liodn, struct d
}
 
info = kmem_cache_zalloc(iommu_devinfo_cache, GFP_ATOMIC);
+   if (!info) {
+   spin_unlock_irqrestore(_domain_lock, flags);
+   return;
+   }
 
info->dev = dev;
info->liodn = liodn;
-- 
2.25.1

___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu