Re: [PATCH net-next v1] net: devmem: NULL check netdev_nl_get_dma_dev return value
From: Jakub Kicinski <kuba@kernel.org>
Date: 2025-08-30 00:52:23
Also in:
lkml
From: Jakub Kicinski <kuba@kernel.org>
Date: 2025-08-30 00:52:23
Also in:
lkml
On Fri, 29 Aug 2025 21:59:38 +0000 Mina Almasry wrote:
netdev_nl_get_dma_dev can return NULL. This happens in the unlikely scenario that netdev->dev.parent is NULL, or all the calls to the ndo_queue_get_dma_dev return NULL from the driver.
I probably have Friday brain but I don't see what you mean.. In net-next net_devmem_bind_dmabuf() gets a dma_dev and returns -EOPNOTSUPP PTR if its NULL.
Current code doesn't NULL check the return value, so it may be passed to net_devmem_bind_dmabuf, which AFAICT will eventually hit WARN_ON(!dmabuf || !dev) in dma_buf_dynamic_attach and do a kernel splat. Avoid this scenario by using IS_ERR_OR_NULL in place of IS_ERR. Found by code inspection. Note that this was a problem even before the fixes patch, since we passed netdev->dev.parent to net_devmem_bind_dmabuf before NULL checking it anyway :( But that code got removed in the fixes patch (and retained the bug).
If the bug exists in net please send a fix for net, and ignore net-next. Maintainers will cope with the merge.