Re: [PATCH 2/2] RDMA/nldev: Guard against NULL ucontext in resource dumps

From: Jason Gunthorpe

Date: Tue Aug 11 2026 - 10:33:07 EST


On Tue, Aug 11, 2026 at 06:56:23PM +0800, Yili Zhang wrote:
> + /*
> + * The uobject's context is cleared by uverbs_destroy_uobject() during
> + * the RDMA_REMOVE_DRIVER_FAILURE fallback path, while the CQ itself is
> + * leaked in the restrack xarray (its destroy failed, so neither the HW
> + * CQ nor the restrack entry can be torn down). A concurrent dump must
> + * not oops when it stumbles onto such a half-destroyed user CQ.
> + */
> + if (!rdma_is_kernel_res(res)) {
> + struct ib_ucontext *ctx =
> + READ_ONCE(cq->uobject->uevent.uobject.context);
> +
> + if (ctx && nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_CTXN,
> + ctx->res.id))
> + return -EMSGSIZE;
> + }

It is missing locking right? This needs to run under the disassociate
srcu probably

Jason