Re: [PATCH] iommu: Initialize domain->handler iniommu_domain_alloc()

From: Joerg Roedel
Date: Thu Dec 15 2011 - 03:10:59 EST


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@xxxxxxxxxxx>
> ---
> 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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/