diff options
author | Gustavo A. R. Silva <gustavoars@kernel.org> | 2022-01-25 22:26:34 +0300 |
---|---|---|
committer | Chanwoo Choi <cw00.choi@samsung.com> | 2022-05-13 11:03:40 +0300 |
commit | 8ae4471d38c4952d8eb67ce60e3988c4ccb25dc6 (patch) | |
tree | 97e203094432ffb0279f427b9c61fc7311582c69 /drivers/extcon/extcon-usbc-cros-ec.c | |
parent | 4c018cc87e5592f5bb8160e6fd42059778e1b0dc (diff) | |
download | linux-8ae4471d38c4952d8eb67ce60e3988c4ccb25dc6.tar.xz |
extcon: usbc-cros-ec: Use struct_size() helper in kzalloc()
Make use of the struct_size() helper instead of an open-coded version,
in order to avoid any potential type mistakes or integer overflows that,
in the worst scenario, could lead to heap overflows.
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Diffstat (limited to 'drivers/extcon/extcon-usbc-cros-ec.c')
-rw-r--r-- | drivers/extcon/extcon-usbc-cros-ec.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/extcon/extcon-usbc-cros-ec.c b/drivers/extcon/extcon-usbc-cros-ec.c index 5290cc2d19d9..fde1db62be0d 100644 --- a/drivers/extcon/extcon-usbc-cros-ec.c +++ b/drivers/extcon/extcon-usbc-cros-ec.c @@ -68,7 +68,7 @@ static int cros_ec_pd_command(struct cros_ec_extcon_info *info, struct cros_ec_command *msg; int ret; - msg = kzalloc(sizeof(*msg) + max(outsize, insize), GFP_KERNEL); + msg = kzalloc(struct_size(msg, data, max(outsize, insize)), GFP_KERNEL); if (!msg) return -ENOMEM; |