summaryrefslogtreecommitdiff
path: root/drivers/pci/ats.c
diff options
context:
space:
mode:
authorGustavo A. R. Silva <gustavoars@kernel.org>2020-05-25 19:43:19 +0300
committerLorenzo Pieralisi <lorenzo.pieralisi@arm.com>2020-05-28 17:37:43 +0300
commitd0684fd0bd79395e074dd668feee5d53b134b1a3 (patch)
treeb3d4cb8b5de9f5acb9764b74ad4466a24f9dff1d /drivers/pci/ats.c
parentc81992e7f4aa19a055dbff5bd6c6d5ff9408f2fb (diff)
downloadlinux-d0684fd0bd79395e074dd668feee5d53b134b1a3.tar.xz
PCI: hv: Use struct_size() helper
One of the more common cases of allocation size calculations is finding the size of a structure that has a zero-sized array at the end, along with memory for some number of elements for that array. For example: struct hv_dr_state { ... struct hv_pcidev_description func[]; }; struct pci_bus_relations { ... struct pci_function_description func[]; } __packed; Make use of the struct_size() helper instead of an open-coded version in order to avoid any potential type mistakes. So, replace the following forms: offsetof(struct hv_dr_state, func) + (sizeof(struct hv_pcidev_description) * (relations->device_count)) offsetof(struct pci_bus_relations, func) + (sizeof(struct pci_function_description) * (bus_rel->device_count)) with: struct_size(dr, func, relations->device_count) and struct_size(bus_rel, func, bus_rel->device_count) respectively. Link: https://lore.kernel.org/r/20200525164319.GA13596@embeddedor Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Reviewed-by: Wei Liu <wei.liu@kernel.org>
Diffstat (limited to 'drivers/pci/ats.c')
0 files changed, 0 insertions, 0 deletions