[PATCH] net: ethernet: mtk_eth_soc: fix misuse of mem alloc interface netdev_alloc_frag

Jakub Kicinski kuba at kernel.org
Thu Jun 2 21:24:15 PDT 2022


On Fri,  3 Jun 2022 12:10:35 +0800 Chen Lin wrote:
> -		ring->data[i] = netdev_alloc_frag(ring->frag_size);
> +		if (ring->frag_size <= PAGE_SIZE)
> +			ring->data[i] = netdev_alloc_frag(ring->frag_size);
> +		else
> +			ring->data[i] = kmalloc(ring->frag_size, GFP_KERNEL);

Is it legal to allocate pages with kmalloc()? I mean they will end up
getting freed by page_frag_free(), not kfree().

Also there's more frag allocations here, search for napi_alloc_frag().




More information about the Linux-mediatek mailing list