1
0
Fork 0
alistair23-linux/drivers/crypto/qat
Gustavo A. R. Silva 1793d1aba1 crypto: qat - 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 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>
2019-06-13 14:31:41 +08:00
..
qat_c3xxx crypto: prefix header search paths with $(srctree)/ 2019-02-01 14:42:05 +08:00
qat_c3xxxvf crypto: prefix header search paths with $(srctree)/ 2019-02-01 14:42:05 +08:00
qat_c62x crypto: prefix header search paths with $(srctree)/ 2019-02-01 14:42:05 +08:00
qat_c62xvf crypto: prefix header search paths with $(srctree)/ 2019-02-01 14:42:05 +08:00
qat_common crypto: qat - use struct_size() helper 2019-06-13 14:31:41 +08:00
qat_dh895xcc crypto: prefix header search paths with $(srctree)/ 2019-02-01 14:42:05 +08:00
qat_dh895xccvf crypto: prefix header search paths with $(srctree)/ 2019-02-01 14:42:05 +08:00
Kconfig crypto: qat - Add DH support 2016-07-11 18:03:10 +08:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00