]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
RDMA/core: Avoid NULL dereference on FRMR bad usage
authorMichael Guralnik <michaelgur@nvidia.com>
Wed, 10 Jun 2026 00:01:42 +0000 (03:01 +0300)
committerJason Gunthorpe <jgg@nvidia.com>
Thu, 11 Jun 2026 18:36:09 +0000 (15:36 -0300)
In case a driver calls FRMR pop operation without a successful init,
return after triggering a warning to avoid the NULL dereference.

Fixes: ce5df0b891ed ("IB/core: Introduce FRMR pools")
Link: https://patch.msgid.link/r/20260610000145.820592-7-michaelgur@nvidia.com
Signed-off-by: Michael Guralnik <michaelgur@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/core/frmr_pools.c

index 1cfdddc3fcdaf6c5cf96ec95247d6b8c15f92847..892aedfe03bed4d79788466ab540b728ef014235 100644 (file)
@@ -529,7 +529,9 @@ int ib_frmr_pool_pop(struct ib_device *device, struct ib_mr *mr)
        struct ib_frmr_pools *pools = device->frmr_pools;
        struct ib_frmr_pool *pool;
 
-       WARN_ON_ONCE(!device->frmr_pools);
+       if (WARN_ON_ONCE(!pools))
+               return -EINVAL;
+
        pool = ib_frmr_pool_find(pools, &mr->frmr.key);
        if (!pool) {
                pool = create_frmr_pool(device, &mr->frmr.key);