Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: bnx2fc: fix bnx2fc_cmd refcount imbalance in send_srr

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 srr_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>

authored by

Lin Yi and committed by
Martin K. Petersen
7bfe5ae5 177709c0

+1 -1
+1 -1
drivers/scsi/bnx2fc/bnx2fc_els.c
··· 654 654 rc = bnx2fc_initiate_els(tgt, ELS_SRR, &srr, sizeof(srr), 655 655 bnx2fc_srr_compl, cb_arg, 656 656 r_a_tov); 657 - srr_err: 658 657 if (rc) { 659 658 BNX2FC_IO_DBG(orig_io_req, "SRR failed - release\n"); 660 659 spin_lock_bh(&tgt->tgt_lock); ··· 663 664 } else 664 665 set_bit(BNX2FC_FLAG_SRR_SENT, &orig_io_req->req_flags); 665 666 667 + srr_err: 666 668 return rc; 667 669 } 668 670