summaryrefslogtreecommitdiff
path: root/drivers/iommu/iommu-debug.c
diff options
context:
space:
mode:
authorMitchel Humpherys <mitchelh@codeaurora.org>2015-07-09 14:50:22 -0700
committerDavid Keitel <dkeitel@codeaurora.org>2016-03-22 11:13:27 -0700
commitfd7f57ccd3a6b27aad34b2356a57a6a8a34c71e2 (patch)
tree3f1b83eefc2d0655525dd7f6a20fdfe244d5e2b7 /drivers/iommu/iommu-debug.c
parent1cbd5563954ad46b8c97522fa7b6f0ce941d6293 (diff)
iommu/iommu-debug: Initialize debug device to 0
Currently the debug device structure is allocated with kmalloc, without initializing all of the fields in the structure. Later, those fields might be uses before they've every been assigned. For example, if a user executes the following code on a fresh boot: # cd /sys/kernel/debug/iommu/tests/some_device # echo 0 > attach The kernel crashes with something like this (assuming page poisoning is enabled): Unable to handle kernel paging request at virtual address aaaaaaaaaaaaaaaa pgd = ffffffc0a92a1000 [aaaaaaaaaaaaaaaa] *pgd=0000000000000000, *pud=0000000000000000 Fix this by initializing all the fields in the structure to 0 by using kzalloc instead of kmalloc. Change-Id: I3514bf7bf174e176ff7a310c7134d0f53e22d771 Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
Diffstat (limited to 'drivers/iommu/iommu-debug.c')
-rw-r--r--drivers/iommu/iommu-debug.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/iommu/iommu-debug.c b/drivers/iommu/iommu-debug.c
index 72ebbac55b77..43c89697b5f4 100644
--- a/drivers/iommu/iommu-debug.c
+++ b/drivers/iommu/iommu-debug.c
@@ -673,7 +673,7 @@ static int snarf_iommu_devices(struct device *dev, void *ignored)
if (!of_find_property(dev->of_node, "iommus", NULL))
return 0;
- ddev = kmalloc(sizeof(*ddev), GFP_KERNEL);
+ ddev = kzalloc(sizeof(*ddev), GFP_KERNEL);
if (!ddev)
return -ENODEV;
ddev->dev = dev;