Linux IOMMU Development
 help / color / mirror / Atom feed
* [PATCH] iommu/dart: Fix return code in apple_dart_domain_alloc_paging()
@ 2023-10-30  9:03 Dan Carpenter
  2023-10-30 11:56 ` Jason Gunthorpe
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2023-10-30  9:03 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Hector Martin, Sven Peter, Alyssa Rosenzweig, Joerg Roedel,
	Will Deacon, Robin Murphy, Janne Grunau, asahi, linux-arm-kernel,
	iommu, kernel-janitors

The apple_dart_domain_alloc_paging() function is supposed to return NULL
on error.  Returning an error pointer will lead to an Oops in
__iommu_domain_alloc().

Fixes: 482feb5c6492 ("iommu/dart: Call apple_dart_finalize_domain() as part of alloc_paging()")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/iommu/apple-dart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c
index ee05f4824bfa..cb38a7a826dc 100644
--- a/drivers/iommu/apple-dart.c
+++ b/drivers/iommu/apple-dart.c
@@ -761,7 +761,7 @@ static struct iommu_domain *apple_dart_domain_alloc_paging(struct device *dev)
 		ret = apple_dart_finalize_domain(dart_domain, cfg);
 		if (ret) {
 			kfree(dart_domain);
-			return ERR_PTR(ret);
+			return NULL;
 		}
 	}
 	return &dart_domain->domain;
-- 
2.42.0


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

* Re: [PATCH] iommu/dart: Fix return code in apple_dart_domain_alloc_paging()
  2023-10-30  9:03 [PATCH] iommu/dart: Fix return code in apple_dart_domain_alloc_paging() Dan Carpenter
@ 2023-10-30 11:56 ` Jason Gunthorpe
  2023-10-30 12:00   ` Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: Jason Gunthorpe @ 2023-10-30 11:56 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Hector Martin, Sven Peter, Alyssa Rosenzweig, Joerg Roedel,
	Will Deacon, Robin Murphy, Janne Grunau, asahi, linux-arm-kernel,
	iommu, kernel-janitors

On Mon, Oct 30, 2023 at 12:03:12PM +0300, Dan Carpenter wrote:
> The apple_dart_domain_alloc_paging() function is supposed to return NULL
> on error.  Returning an error pointer will lead to an Oops in
> __iommu_domain_alloc().
> 
> Fixes: 482feb5c6492 ("iommu/dart: Call apple_dart_finalize_domain() as part of alloc_paging()")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  drivers/iommu/apple-dart.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>

Really need to fix this so the function does return ERR_PTR..

Thanks,
Jason

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

* Re: [PATCH] iommu/dart: Fix return code in apple_dart_domain_alloc_paging()
  2023-10-30 11:56 ` Jason Gunthorpe
@ 2023-10-30 12:00   ` Dan Carpenter
  2023-10-30 12:38     ` Jason Gunthorpe
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2023-10-30 12:00 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Hector Martin, Sven Peter, Alyssa Rosenzweig, Joerg Roedel,
	Will Deacon, Robin Murphy, Janne Grunau, asahi, linux-arm-kernel,
	iommu, kernel-janitors

On Mon, Oct 30, 2023 at 08:56:50AM -0300, Jason Gunthorpe wrote:
> On Mon, Oct 30, 2023 at 12:03:12PM +0300, Dan Carpenter wrote:
> > The apple_dart_domain_alloc_paging() function is supposed to return NULL
> > on error.  Returning an error pointer will lead to an Oops in
> > __iommu_domain_alloc().
> > 
> > Fixes: 482feb5c6492 ("iommu/dart: Call apple_dart_finalize_domain() as part of alloc_paging()")
> > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> > ---
> >  drivers/iommu/apple-dart.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
> 
> Really need to fix this so the function does return ERR_PTR..

It's called as a function pointer.  Changing that will create a
backporting hazard unless we rename the pointer or something.

regards,
dan carpenter


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

* Re: [PATCH] iommu/dart: Fix return code in apple_dart_domain_alloc_paging()
  2023-10-30 12:00   ` Dan Carpenter
@ 2023-10-30 12:38     ` Jason Gunthorpe
  2023-11-01  0:47       ` Jason Gunthorpe
  0 siblings, 1 reply; 5+ messages in thread
From: Jason Gunthorpe @ 2023-10-30 12:38 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Hector Martin, Sven Peter, Alyssa Rosenzweig, Joerg Roedel,
	Will Deacon, Robin Murphy, Janne Grunau, asahi, linux-arm-kernel,
	iommu, kernel-janitors

On Mon, Oct 30, 2023 at 03:00:56PM +0300, Dan Carpenter wrote:
> On Mon, Oct 30, 2023 at 08:56:50AM -0300, Jason Gunthorpe wrote:
> > On Mon, Oct 30, 2023 at 12:03:12PM +0300, Dan Carpenter wrote:
> > > The apple_dart_domain_alloc_paging() function is supposed to return NULL
> > > on error.  Returning an error pointer will lead to an Oops in
> > > __iommu_domain_alloc().
> > > 
> > > Fixes: 482feb5c6492 ("iommu/dart: Call apple_dart_finalize_domain() as part of alloc_paging()")
> > > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> > > ---
> > >  drivers/iommu/apple-dart.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
> > 
> > Really need to fix this so the function does return ERR_PTR..
> 
> It's called as a function pointer.  Changing that will create a
> backporting hazard unless we rename the pointer or something.

You can make that argument about almost any change in the kernel..

IMHO we needed an annotation like __user/__iomem/etc to indicate
ERR_PTR so at least there is some hope of trivially finding it.

Jason

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

* Re: [PATCH] iommu/dart: Fix return code in apple_dart_domain_alloc_paging()
  2023-10-30 12:38     ` Jason Gunthorpe
@ 2023-11-01  0:47       ` Jason Gunthorpe
  0 siblings, 0 replies; 5+ messages in thread
From: Jason Gunthorpe @ 2023-11-01  0:47 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Hector Martin, Sven Peter, Alyssa Rosenzweig, Joerg Roedel,
	Will Deacon, Robin Murphy, Janne Grunau, asahi, linux-arm-kernel,
	iommu, kernel-janitors

On Mon, Oct 30, 2023 at 09:38:23AM -0300, Jason Gunthorpe wrote:
> On Mon, Oct 30, 2023 at 03:00:56PM +0300, Dan Carpenter wrote:
> > On Mon, Oct 30, 2023 at 08:56:50AM -0300, Jason Gunthorpe wrote:
> > > On Mon, Oct 30, 2023 at 12:03:12PM +0300, Dan Carpenter wrote:
> > > > The apple_dart_domain_alloc_paging() function is supposed to return NULL
> > > > on error.  Returning an error pointer will lead to an Oops in
> > > > __iommu_domain_alloc().
> > > > 
> > > > Fixes: 482feb5c6492 ("iommu/dart: Call apple_dart_finalize_domain() as part of alloc_paging()")
> > > > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> > > > ---
> > > >  drivers/iommu/apple-dart.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
> > > 
> > > Really need to fix this so the function does return ERR_PTR..
> > 
> > It's called as a function pointer.  Changing that will create a
> > backporting hazard unless we rename the pointer or something.
> 
> You can make that argument about almost any change in the kernel..
> 
> IMHO we needed an annotation like __user/__iomem/etc to indicate
> ERR_PTR so at least there is some hope of trivially finding it.

I was thinking about this some more, I think I prefer we fix the core
code to accept the ERR_PTR and just start moving gently in that
direction. I was working on some other stuff and it is starting to get
really confusing that only this op is different.

I'll send a patch

Jason

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

end of thread, other threads:[~2023-11-01  0:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-30  9:03 [PATCH] iommu/dart: Fix return code in apple_dart_domain_alloc_paging() Dan Carpenter
2023-10-30 11:56 ` Jason Gunthorpe
2023-10-30 12:00   ` Dan Carpenter
2023-10-30 12:38     ` Jason Gunthorpe
2023-11-01  0:47       ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox