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 qat_alg_buf_list {
...
struct qat_alg_buf bufers[];
} __packed __aligned(64);
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 form:
sizeof(struct qat_alg_buf_list) + ((1 + n) * sizeof(struct qat_alg_buf))
with:
struct_size(bufl, bufers, n + 1)
This code was detected with the help of Coccinelle.
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||
|---|---|---|
| .. | ||
| adf_accel_devices.h | ||
| adf_accel_engine.c | ||
| adf_admin.c | ||
| adf_aer.c | ||
| adf_cfg_common.h | ||
| adf_cfg_strings.h | ||
| adf_cfg_user.h | ||
| adf_cfg.c | ||
| adf_cfg.h | ||
| adf_common_drv.h | ||
| adf_ctl_drv.c | ||
| adf_dev_mgr.c | ||
| adf_hw_arbiter.c | ||
| adf_init.c | ||
| adf_isr.c | ||
| adf_pf2vf_msg.c | ||
| adf_pf2vf_msg.h | ||
| adf_sriov.c | ||
| adf_transport_access_macros.h | ||
| adf_transport_debug.c | ||
| adf_transport_internal.h | ||
| adf_transport.c | ||
| adf_transport.h | ||
| adf_vf2pf_msg.c | ||
| adf_vf_isr.c | ||
| icp_qat_fw_init_admin.h | ||
| icp_qat_fw_la.h | ||
| icp_qat_fw_loader_handle.h | ||
| icp_qat_fw_pke.h | ||
| icp_qat_fw.h | ||
| icp_qat_hal.h | ||
| icp_qat_hw.h | ||
| icp_qat_uclo.h | ||
| Makefile | ||
| qat_algs.c | ||
| qat_asym_algs.c | ||
| qat_crypto.c | ||
| qat_crypto.h | ||
| qat_hal.c | ||
| qat_uclo.c | ||