Skip to content

Commit

Permalink
scsi: bnx2fc: fix bnx2fc_cmd refcount imbalance in send_rec
Browse files Browse the repository at this point in the history
If cb_arg alloc failed, we can't release the struct orig_io_req refcount
before we take its refcount. As Saurav said, move the rec_err label down
to avoid unnecessary refcount release and nullptr free.

Signed-off-by: Lin Yi <teroincn@163.com>
Acked-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
  • Loading branch information
Lin Yi authored and Martin K. Petersen committed Jun 27, 2019
1 parent 10b3ef2 commit 177709c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/scsi/bnx2fc/bnx2fc_els.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,14 +610,14 @@ int bnx2fc_send_rec(struct bnx2fc_cmd *orig_io_req)
rc = bnx2fc_initiate_els(tgt, ELS_REC, &rec, sizeof(rec),
bnx2fc_rec_compl, cb_arg,
r_a_tov);
rec_err:
if (rc) {
BNX2FC_IO_DBG(orig_io_req, "REC failed - release\n");
spin_lock_bh(&tgt->tgt_lock);
kref_put(&orig_io_req->refcount, bnx2fc_cmd_release);
spin_unlock_bh(&tgt->tgt_lock);
kfree(cb_arg);
}
rec_err:
return rc;
}

Expand Down

0 comments on commit 177709c

Please sign in to comment.