linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iommu: Initialize domain->handler in iommu_domain_alloc()
@ 2011-12-13  7:14 KyongHo Cho
  2011-12-15  8:10 ` Joerg Roedel
  0 siblings, 1 reply; 4+ messages in thread
From: KyongHo Cho @ 2011-12-13  7:14 UTC (permalink / raw)
  To: linux-arm-kernel

Since it is not guaranteed that an iommu driver initializes in its
domain_init() function, it must be initialized with NULL to prevent
calling a function in an arbitrary location when iommu fault occurred.

Signed-off-by: KyongHo Cho <pullip.cho@samsung.com>
---
 drivers/iommu/iommu.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 7cc3c65..1afb896 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -148,6 +148,7 @@ struct iommu_domain *iommu_domain_alloc(struct bus_type *bus)
 		return NULL;
 
 	domain->ops = bus->iommu_ops;
+	domain->handler = NULL;
 
 	ret = domain->ops->domain_init(domain);
 	if (ret)
-- 
1.7.1

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

* [PATCH] iommu: Initialize domain->handler in iommu_domain_alloc()
  2011-12-13  7:14 [PATCH] iommu: Initialize domain->handler in iommu_domain_alloc() KyongHo Cho
@ 2011-12-15  8:10 ` Joerg Roedel
  2011-12-16 12:38   ` KyongHo Cho
  0 siblings, 1 reply; 4+ messages in thread
From: Joerg Roedel @ 2011-12-15  8:10 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Dec 13, 2011 at 04:14:26PM +0900, KyongHo Cho wrote:
> Since it is not guaranteed that an iommu driver initializes in its
> domain_init() function, it must be initialized with NULL to prevent
> calling a function in an arbitrary location when iommu fault occurred.
> 
> Signed-off-by: KyongHo Cho <pullip.cho@samsung.com>
> ---
>  drivers/iommu/iommu.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index 7cc3c65..1afb896 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -148,6 +148,7 @@ struct iommu_domain *iommu_domain_alloc(struct bus_type *bus)
>  		return NULL;
>  
>  	domain->ops = bus->iommu_ops;
> +	domain->handler = NULL;

Good catch. But it is better to change the kmalloc in the function to
kzalloc. This will implicitly initialize all future members correctly.

Thanks,

	Joerg

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

* [PATCH] iommu: Initialize domain->handler in iommu_domain_alloc()
  2011-12-15  8:10 ` Joerg Roedel
@ 2011-12-16 12:38   ` KyongHo Cho
  2011-12-16 14:15     ` 'Joerg Roedel'
  0 siblings, 1 reply; 4+ messages in thread
From: KyongHo Cho @ 2011-12-16 12:38 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Dec 15, 2011 at 05:11:26PM +0100, Joerg Roedel wrote:
> On Tue, Dec 13, 2011 at 04:14:20PM +0900, KyongHo Cho wrote:
> > Since it is not guaranteed that an iommu driver initializes in its
> > domain_init() function, it must be initialized with NULL to prevent
> > calling a function in an arbitrary location when iommu fault occurred.
> >
> > Signed-off-by: KyongHo Cho <pullip.cho@samsung.com>
> > ---
> >  drivers/iommu/iommu.c |    1 +
> >  1 files changed, 1 insertions(+), 0 deletions(-)
> >
> > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> > index 7cc3c65..1afb896 100644
> > --- a/drivers/iommu/iommu.c
> > +++ b/drivers/iommu/iommu.c
> > @@ -148,6 +148,7 @@ struct iommu_domain *iommu_domain_alloc(struct
> bus_type *bus)
> >  		return NULL;
> >
> >  	domain->ops = bus->iommu_ops;
> > +	domain->handler = NULL;
> 
> Good catch. But it is better to change the kmalloc in the function to
> kzalloc. This will implicitly initialize all future members correctly.
Hi.

Here is the patch that change kmalloc -> kzalloc
according to your advice.

>From 821141fcf00a64fe4fbacc78b2bbe90e15da9fca Mon Sep 17 00:00:00 2001
From: KyongHo Cho <pullip.cho@samsung.com>
Date: Tue, 13 Dec 2011 16:08:51 +0900
Subject: [PATCH] iommu: Initialize domain->handler in iommu_domain_alloc()

Since it is not guaranteed that an iommu driver initializes in its
domain_init() function, it must be initialized with NULL to prevent
calling a function in an arbitrary location when iommu fault occurred.

Signed-off-by: KyongHo Cho <pullip.cho@samsung.com>
---
 drivers/iommu/iommu.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 7cc3c65..2198b2d 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -143,7 +143,7 @@ struct iommu_domain *iommu_domain_alloc(struct bus_type *bus)
 	if (bus == NULL || bus->iommu_ops == NULL)
 		return NULL;
 
-	domain = kmalloc(sizeof(*domain), GFP_KERNEL);
+	domain = kzalloc(sizeof(*domain), GFP_KERNEL);
 	if (!domain)
 		return NULL;
 
-- 
1.7.1

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

* [PATCH] iommu: Initialize domain->handler in iommu_domain_alloc()
  2011-12-16 12:38   ` KyongHo Cho
@ 2011-12-16 14:15     ` 'Joerg Roedel'
  0 siblings, 0 replies; 4+ messages in thread
From: 'Joerg Roedel' @ 2011-12-16 14:15 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Dec 16, 2011 at 09:38:25PM +0900, KyongHo Cho wrote:
> Subject: [PATCH] iommu: Initialize domain->handler in iommu_domain_alloc()
> 
> Since it is not guaranteed that an iommu driver initializes in its
> domain_init() function, it must be initialized with NULL to prevent
> calling a function in an arbitrary location when iommu fault occurred.
> 
> Signed-off-by: KyongHo Cho <pullip.cho@samsung.com>

Applied to iommu/fixes, thanks a lot.

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

end of thread, other threads:[~2011-12-16 14:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-13  7:14 [PATCH] iommu: Initialize domain->handler in iommu_domain_alloc() KyongHo Cho
2011-12-15  8:10 ` Joerg Roedel
2011-12-16 12:38   ` KyongHo Cho
2011-12-16 14:15     ` 'Joerg Roedel'

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).