iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers/iommu: fix a null-ptr-deref bug in fsl_pamu_domain.c
@ 2020-12-09 12:34 tangzhenhao
  2020-12-10  9:14 ` Will Deacon
  0 siblings, 1 reply; 2+ messages in thread
From: tangzhenhao @ 2020-12-09 12:34 UTC (permalink / raw)
  To: iommu; +Cc: tangzhenhao

    At line 362 in drivers/iommu/fsl_pamu_domain.c, the ret-val of kmem_cache_zalloc should be checked to avoid null-ptr-deref bug.

Signed-off-by: tangzhenhao <tzh18@mails.tsinghua.edu.cn>
---
 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 b2110767caf4..9ebd5135f4a8 100644
--- a/drivers/iommu/fsl_pamu_domain.c
+++ b/drivers/iommu/fsl_pamu_domain.c
@@ -360,6 +360,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) {
+		pr_debug("device_domain_info allocation failed\n");
+		return;
+	}
 
 	info->dev = dev;
 	info->liodn = liodn;
-- 
2.17.1

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

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

* Re: [PATCH] drivers/iommu: fix a null-ptr-deref bug in fsl_pamu_domain.c
  2020-12-09 12:34 [PATCH] drivers/iommu: fix a null-ptr-deref bug in fsl_pamu_domain.c tangzhenhao
@ 2020-12-10  9:14 ` Will Deacon
  0 siblings, 0 replies; 2+ messages in thread
From: Will Deacon @ 2020-12-10  9:14 UTC (permalink / raw)
  To: tangzhenhao; +Cc: iommu

On Wed, Dec 09, 2020 at 04:34:30AM -0800, tangzhenhao wrote:
>     At line 362 in drivers/iommu/fsl_pamu_domain.c, the ret-val of kmem_cache_zalloc should be checked to avoid null-ptr-deref bug.
> 
> Signed-off-by: tangzhenhao <tzh18@mails.tsinghua.edu.cn>
> ---
>  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 b2110767caf4..9ebd5135f4a8 100644
> --- a/drivers/iommu/fsl_pamu_domain.c
> +++ b/drivers/iommu/fsl_pamu_domain.c
> @@ -360,6 +360,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) {
> +		pr_debug("device_domain_info allocation failed\n");
> +		return;
> +	}

All the comments I made on your other patch [1] apply to this one too.

Will

[1] https://lore.kernel.org/r/20201210091326.GA9633@willie-the-truck
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

end of thread, other threads:[~2020-12-10  9:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-09 12:34 [PATCH] drivers/iommu: fix a null-ptr-deref bug in fsl_pamu_domain.c tangzhenhao
2020-12-10  9:14 ` Will Deacon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).