Re: [PATCH bpf-next v1 1/5] bpf: Make every prog keep a copy of ctx_arg_info

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Feb 14, 2025 at 8:45 AM Amery Hung <ameryhung@xxxxxxxxx> wrote:
>
>
> +int bpf_prog_ctx_arg_info_init(struct bpf_prog *prog,
> +                              const struct bpf_ctx_arg_aux *info, u32 cnt)
> +{
> +       prog->aux->ctx_arg_info = kcalloc(cnt, sizeof(*info), GFP_KERNEL);

could have been kmalloc_array.

> +       if (!prog->aux->ctx_arg_info)
> +               return -ENOMEM;
> +
> +       memcpy(prog->aux->ctx_arg_info, info, sizeof(*info) * cnt);

Please use kmemdup().
Otherwise cocci fans will send a patch for this tomorrow.
imo kmalloc+memcpy is fine, but, sigh, cocci.

pw-bot: cr





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux