Re: [PATCH bpf-next 1/2] xsk: store struct xdp_sock as a flexible array member of the XSKMAP

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

 



On Thu, 24 Oct 2019 09:19:30 +0200, Maciej Fijalkowski wrote:
> @@ -92,44 +94,36 @@ static struct bpf_map *xsk_map_alloc(union bpf_attr *attr)
>  	    attr->map_flags & ~(BPF_F_NUMA_NODE | BPF_F_RDONLY | BPF_F_WRONLY))
>  		return ERR_PTR(-EINVAL);
>  
> -	m = kzalloc(sizeof(*m), GFP_USER);
> -	if (!m)
> -		return ERR_PTR(-ENOMEM);
> +	max_entries = attr->max_entries;
>  
> -	bpf_map_init_from_attr(&m->map, attr);
> -	spin_lock_init(&m->lock);
> +	size = sizeof(*m) + max_entries * sizeof(m->xsk_map[0]);

Maybe the array_size() I suggested to Toke was disputable, but this is
such an struct_size()...

Otherwise you probably need an explicit (u64) cast?



[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