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_rec

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>

authored by

Lin Yi and committed by
Martin K. Petersen
177709c0 10b3ef22

+1 -1
+1 -1
drivers/scsi/bnx2fc/bnx2fc_els.c
··· 610 610 rc = bnx2fc_initiate_els(tgt, ELS_REC, &rec, sizeof(rec), 611 611 bnx2fc_rec_compl, cb_arg, 612 612 r_a_tov); 613 - rec_err: 614 613 if (rc) { 615 614 BNX2FC_IO_DBG(orig_io_req, "REC failed - release\n"); 616 615 spin_lock_bh(&tgt->tgt_lock); ··· 617 618 spin_unlock_bh(&tgt->tgt_lock); 618 619 kfree(cb_arg); 619 620 } 621 + rec_err: 620 622 return rc; 621 623 } 622 624