]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
net: fec: handle page_pool_dev_alloc_pages error
authorKevin Groeneveld <kgroeneveld@lenbrook.com>
Mon, 13 Jan 2025 15:48:45 +0000 (10:48 -0500)
committerJakub Kicinski <kuba@kernel.org>
Wed, 15 Jan 2025 02:39:11 +0000 (18:39 -0800)
commit001ba0902046cb6c352494df610718c0763e77a5
treeb5800679a74c2dc17e9d81ce53044d3004302935
parentf0d0277796db613c124206544b6dbe95b520ab6c
net: fec: handle page_pool_dev_alloc_pages error

The fec_enet_update_cbd function calls page_pool_dev_alloc_pages but did
not handle the case when it returned NULL. There was a WARN_ON(!new_page)
but it would still proceed to use the NULL pointer and then crash.

This case does seem somewhat rare but when the system is under memory
pressure it can happen. One case where I can duplicate this with some
frequency is when writing over a smbd share to a SATA HDD attached to an
imx6q.

Setting /proc/sys/vm/min_free_kbytes to higher values also seems to solve
the problem for my test case. But it still seems wrong that the fec driver
ignores the memory allocation error and can crash.

This commit handles the allocation error by dropping the current packet.

Fixes: 95698ff6177b5 ("net: fec: using page pool to manage RX buffers")
Signed-off-by: Kevin Groeneveld <kgroeneveld@lenbrook.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed-by: Wei Fang <wei.fang@nxp.com>
Link: https://patch.msgid.link/20250113154846.1765414-1-kgroeneveld@lenbrook.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/freescale/fec_main.c