IB/hfi1: Prevent a NULL dereference

In the original code, we set "fd->uctxt" to NULL and then dereference it
which will cause an Oops.

Fixes: f2a3bc00a03c ("IB/hfi1: Protect context array set/clear with spinlock")
Cc: <stable@vger.kernel.org> # 4.14.x
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>

authored by Dan Carpenter and committed by Doug Ledford 57194fa7 cd52cb26

+2 -2
+2 -2
drivers/infiniband/hw/hfi1/file_ops.c
··· 763 } 764 765 if (ret) { 766 - hfi1_rcd_put(fd->uctxt); 767 - fd->uctxt = NULL; 768 spin_lock_irqsave(&fd->dd->uctxt_lock, flags); 769 __clear_bit(fd->subctxt, fd->uctxt->in_use_ctxts); 770 spin_unlock_irqrestore(&fd->dd->uctxt_lock, flags); 771 } 772 773 return ret;
··· 763 } 764 765 if (ret) { 766 spin_lock_irqsave(&fd->dd->uctxt_lock, flags); 767 __clear_bit(fd->subctxt, fd->uctxt->in_use_ctxts); 768 spin_unlock_irqrestore(&fd->dd->uctxt_lock, flags); 769 + hfi1_rcd_put(fd->uctxt); 770 + fd->uctxt = NULL; 771 } 772 773 return ret;