Commit d6f75d86 authored by Yu Jiaoliang's avatar Yu Jiaoliang Committed by Paolo Abeni

nfp: bpf: Use kmemdup_array instead of kmemdup for multiple allocation

Let the kememdup_array() take care about multiplication and possible
overflows.
Signed-off-by: default avatarYu Jiaoliang <yujiaoliang@vivo.com>
Signed-off-by: default avatarLouis Peens <louis.peens@corigine.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20240821081447.12430-1-yujiaoliang@vivo.comSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 812a2751
...@@ -4537,8 +4537,8 @@ void *nfp_bpf_relo_for_vnic(struct nfp_prog *nfp_prog, struct nfp_bpf_vnic *bv) ...@@ -4537,8 +4537,8 @@ void *nfp_bpf_relo_for_vnic(struct nfp_prog *nfp_prog, struct nfp_bpf_vnic *bv)
u64 *prog; u64 *prog;
int err; int err;
prog = kmemdup(nfp_prog->prog, nfp_prog->prog_len * sizeof(u64), prog = kmemdup_array(nfp_prog->prog, nfp_prog->prog_len, sizeof(u64),
GFP_KERNEL); GFP_KERNEL);
if (!prog) if (!prog)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment