IB/hfi1: Prevent null pointer dereference

If a context has not been assigned or assignment failed, pq may be NULL.
Move the unregister within the protection of the null check.

Reviewed-by: Dean Luick <dean.luick@intel.com>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
This commit is contained in:
Ira Weiny 2016-07-28 15:21:12 -04:00 committed by Doug Ledford
parent a7cd2dc5d4
commit 53445bb32d
1 changed files with 1 additions and 1 deletions

View File

@ -472,8 +472,8 @@ int hfi1_user_sdma_free_queues(struct hfi1_filedata *fd)
hfi1_cdbg(SDMA, "[%u:%u:%u] Freeing user SDMA queues", uctxt->dd->unit,
uctxt->ctxt, fd->subctxt);
pq = fd->pq;
hfi1_mmu_rb_unregister(&pq->sdma_rb_root);
if (pq) {
hfi1_mmu_rb_unregister(&pq->sdma_rb_root);
spin_lock_irqsave(&uctxt->sdma_qlock, flags);
if (!list_empty(&pq->list))
list_del_init(&pq->list);