mirror of
https://github.com/torvalds/linux.git
synced 2024-11-15 00:21:59 +00:00
c886ec0256
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 samsung_usb2_phy_driver { ... struct samsung_usb2_phy_instance instances[0]; }; instance = devm_kzalloc(dev, sizeof(struct samsung_usb2_phy_driver) + count * sizeof(struct samsung_usb2_phy_instance), GFP_KERNEL); Instead of leaving these open-coded and prone to type mistakes, we can now use the new struct_size() helper: instance = devm_kzalloc(dev, struct_size(instance, instances, count), GFP_KERNEL); This code was detected with the help of Coccinelle. Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> |
||
---|---|---|
.. | ||
Kconfig | ||
Makefile | ||
phy-exynos4x12-usb2.c | ||
phy-exynos5-usbdrd.c | ||
phy-exynos4210-usb2.c | ||
phy-exynos5250-sata.c | ||
phy-exynos5250-usb2.c | ||
phy-exynos-dp-video.c | ||
phy-exynos-mipi-video.c | ||
phy-exynos-pcie.c | ||
phy-s5pv210-usb2.c | ||
phy-samsung-usb2.c | ||
phy-samsung-usb2.h |