Skip to content

Commit 57194fa

Browse files
Dan Carpenterdledford
authored andcommitted
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: f2a3bc0 ("IB/hfi1: Protect context array set/clear with spinlock") Cc: <[email protected]> # 4.14.x Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Michael J. Ruhl <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent cd52cb2 commit 57194fa

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/infiniband/hw/hfi1/file_ops.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -763,11 +763,11 @@ static int complete_subctxt(struct hfi1_filedata *fd)
763763
}
764764

765765
if (ret) {
766-
hfi1_rcd_put(fd->uctxt);
767-
fd->uctxt = NULL;
768766
spin_lock_irqsave(&fd->dd->uctxt_lock, flags);
769767
__clear_bit(fd->subctxt, fd->uctxt->in_use_ctxts);
770768
spin_unlock_irqrestore(&fd->dd->uctxt_lock, flags);
769+
hfi1_rcd_put(fd->uctxt);
770+
fd->uctxt = NULL;
771771
}
772772

773773
return ret;

0 commit comments

Comments
 (0)