提交 8ae4471d 编写于 作者: G Gustavo A. R. Silva 提交者: Chanwoo Choi

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: NGustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: NChanwoo Choi <cw00.choi@samsung.com>
上级 4c018cc8
...@@ -68,7 +68,7 @@ static int cros_ec_pd_command(struct cros_ec_extcon_info *info, ...@@ -68,7 +68,7 @@ static int cros_ec_pd_command(struct cros_ec_extcon_info *info,
struct cros_ec_command *msg; struct cros_ec_command *msg;
int ret; int ret;
msg = kzalloc(sizeof(*msg) + max(outsize, insize), GFP_KERNEL); msg = kzalloc(struct_size(msg, data, max(outsize, insize)), GFP_KERNEL);
if (!msg) if (!msg)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册