[PATCH 03/11] net: ethernet: mtk_eth_soc: add support for Wireless Ethernet Dispatch (WED)

Felix Fietkau nbd at nbd.name
Wed Mar 2 22:58:54 PST 2022


On 26.02.22 07:18, Jakub Kicinski wrote:
> On Fri, 25 Feb 2022 11:18:02 +0100 Felix Fietkau wrote:
>> +	page_list = kcalloc(n_pages, sizeof(*page_list), GFP_KERNEL);
>> +	if (!page_list)
>> +		return -ENOMEM;
>> +
>> +	dev->buf_ring.size = ring_size;
>> +	dev->buf_ring.pages = page_list;
>> +
>> +	desc = dma_alloc_coherent(dev->hw->dev, ring_size * sizeof(*desc),
>> +				  &desc_phys, GFP_KERNEL);
>> +	if (!desc)
>> +		return -ENOMEM;
>> +
>> +	dev->buf_ring.desc = desc;
>> +	dev->buf_ring.desc_phys = desc_phys;
>> +
>> +	for (i = 0, page_idx = 0; i < ring_size; i += MTK_WED_BUF_PER_PAGE) {
>> +		dma_addr_t page_phys, buf_phys;
>> +		struct page *page;
>> +		void *buf;
>> +		int s;
>> +
>> +		page = __dev_alloc_pages(GFP_KERNEL, 0);
>> +		if (!page)
>> +			return -ENOMEM;
> 
> I haven't looked at the code, yet, but this sure looks leaky.
It's not leaky. If the alloc fails, mtk_wed_detach is still called, 
which cleans up even incomplete ring allocations.

- Felix



More information about the Linux-mediatek mailing list