diff options
author | Minghao Chi (CGEL ZTE) <[email protected]> | 2022-02-16 03:07:20 +0000 |
---|---|---|
committer | Bjorn Andersson <[email protected]> | 2022-03-11 14:24:55 -0600 |
commit | 18fc82d6e899be54fcf43b28e588e28f09c8810f (patch) | |
tree | e6f4a7766c2b5754d8e726903075289b02c3c4a5 | |
parent | a8f8cc6b39b7ee0dbaccbebd1268c9d3458ebf13 (diff) |
rpmsg: use struct_size over open coded arithmetic
Replace zero-length array with flexible-array member and make use
of the struct_size() helper in kzalloc(). For example:
struct glink_defer_cmd {
struct list_head node;
struct glink_msg msg;
u8 data[];
};
Make use of the struct_size() helper instead of an open-coded version
in order to avoid any potential type mistakes.
Reported-by: Zeal Robot <[email protected]>
Signed-off-by: Minghao Chi (CGEL ZTE) <[email protected]>
Signed-off-by: Bjorn Andersson <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
-rw-r--r-- | drivers/rpmsg/qcom_glink_native.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index 1030cfa80e04..f4f4e392d0d1 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -792,7 +792,7 @@ static int qcom_glink_rx_defer(struct qcom_glink *glink, size_t extra) return -ENXIO; } - dcmd = kzalloc(sizeof(*dcmd) + extra, GFP_ATOMIC); + dcmd = kzalloc(struct_size(dcmd, data, extra), GFP_ATOMIC); if (!dcmd) return -ENOMEM; |