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>
This commit is contained in:
parent
1cbd556395
commit
fd7f57ccd3
1 changed files with 1 additions and 1 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue