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. 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). Fixes: b8aab4bb9585 ("net: devmem: allow binding on rx queues with same DMA devices") Signed-off-by: Mina Almasry --- net/core/netdev-genl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c index 470fabbeacd9..779bcdb5653d 100644 --- a/net/core/netdev-genl.c +++ b/net/core/netdev-genl.c @@ -1098,7 +1098,7 @@ int netdev_nl_bind_tx_doit(struct sk_buff *skb, struct genl_info *info) dma_dev = netdev_queue_get_dma_dev(netdev, 0); binding = net_devmem_bind_dmabuf(netdev, dma_dev, DMA_TO_DEVICE, dmabuf_fd, priv, info->extack); - if (IS_ERR(binding)) { + if (IS_ERR_OR_NULL(binding)) { err = PTR_ERR(binding); goto err_unlock_netdev; } base-commit: 4f54dff818d7b5b1d84becd5d90bc46e6233c0d7 -- 2.51.0.318.gd7df087d1a-goog