if cb_arg alloc failed, we can't release the struct orig_io_req refcount
before we take it's refcount. call kref_get before malloc, so as to pair
with kref_put on rec_err path.

Signed-off-by: Lin Yi <teroi...@163.com>
---
 drivers/scsi/bnx2fc/bnx2fc_els.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_els.c b/drivers/scsi/bnx2fc/bnx2fc_els.c
index 76e65a3..709bb92 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_els.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_els.c
@@ -592,13 +592,13 @@ int bnx2fc_send_rec(struct bnx2fc_cmd *orig_io_req)
        BNX2FC_IO_DBG(orig_io_req, "Sending REC\n");
        memset(&rec, 0, sizeof(rec));
 
+       kref_get(&orig_io_req->refcount);
        cb_arg = kzalloc(sizeof(struct bnx2fc_els_cb_arg), GFP_ATOMIC);
        if (!cb_arg) {
                printk(KERN_ERR PFX "Unable to allocate cb_arg for REC\n");
                rc = -ENOMEM;
                goto rec_err;
        }
-       kref_get(&orig_io_req->refcount);
 
        cb_arg->aborted_io_req = orig_io_req;
 
-- 
1.9.1


Reply via email to