Commit 553d66cb authored by Gustavo A. R. Silva's avatar Gustavo A. R. Silva Committed by Joerg Roedel

iommu/vt-d: Use struct_size() helper

Make use of the struct_size() helper instead of an open-coded version
in order to avoid any potential type mistakes, in particular in the
context in which this code is being used.

So, replace code of the following form:

size = sizeof(*info) + level * sizeof(info->path[0]);

with:

size = struct_size(info, path, level);
Signed-off-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent f7b0c4ce
...@@ -145,7 +145,7 @@ dmar_alloc_pci_notify_info(struct pci_dev *dev, unsigned long event) ...@@ -145,7 +145,7 @@ dmar_alloc_pci_notify_info(struct pci_dev *dev, unsigned long event)
for (tmp = dev; tmp; tmp = tmp->bus->self) for (tmp = dev; tmp; tmp = tmp->bus->self)
level++; level++;
size = sizeof(*info) + level * sizeof(info->path[0]); size = struct_size(info, path, level);
if (size <= sizeof(dmar_pci_notify_info_buf)) { if (size <= sizeof(dmar_pci_notify_info_buf)) {
info = (struct dmar_pci_notify_info *)dmar_pci_notify_info_buf; info = (struct dmar_pci_notify_info *)dmar_pci_notify_info_buf;
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment