diff options
author | Jayamohan Kallickal <jayamohank@serverengines.com> | 2010-07-21 18:57:47 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2010-07-28 10:05:37 -0400 |
commit | 3cbb7a74a76e45f5e410367259844e8266fba6ec (patch) | |
tree | 0fecd55bd62d80961a0dd7c3fba3523fe8ab5e93 /drivers/scsi/be2iscsi/be_iscsi.c | |
parent | 0aa094331b19e54f928e2ac083285ff68d91c69b (diff) |
[SCSI] be2iscsi: Fix for premature buffer free
This patch fixes a bug where the buffer was being freed as soon as
submission to HW is done.
Signed-off-by: Jayamohan Kallickal <jayamohank@serverengines.com>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/be2iscsi/be_iscsi.c')
-rw-r--r-- | drivers/scsi/be2iscsi/be_iscsi.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c index a131a576a102..6d63e7b312cf 100644 --- a/drivers/scsi/be2iscsi/be_iscsi.c +++ b/drivers/scsi/be2iscsi/be_iscsi.c | |||
@@ -488,6 +488,7 @@ static int beiscsi_open_conn(struct iscsi_endpoint *ep, | |||
488 | struct be_mcc_wrb *wrb; | 488 | struct be_mcc_wrb *wrb; |
489 | struct tcp_connect_and_offload_out *ptcpcnct_out; | 489 | struct tcp_connect_and_offload_out *ptcpcnct_out; |
490 | unsigned short status, extd_status; | 490 | unsigned short status, extd_status; |
491 | struct be_dma_mem nonemb_cmd; | ||
491 | unsigned int tag, wrb_num; | 492 | unsigned int tag, wrb_num; |
492 | int ret = -ENOMEM; | 493 | int ret = -ENOMEM; |
493 | 494 | ||
@@ -504,16 +505,31 @@ static int beiscsi_open_conn(struct iscsi_endpoint *ep, | |||
504 | if (beiscsi_ep->ep_cid > (phba->fw_config.iscsi_cid_start + | 505 | if (beiscsi_ep->ep_cid > (phba->fw_config.iscsi_cid_start + |
505 | phba->params.cxns_per_ctrl * 2)) { | 506 | phba->params.cxns_per_ctrl * 2)) { |
506 | SE_DEBUG(DBG_LVL_1, "Failed in allocate iscsi cid\n"); | 507 | SE_DEBUG(DBG_LVL_1, "Failed in allocate iscsi cid\n"); |
508 | beiscsi_put_cid(phba, beiscsi_ep->ep_cid); | ||
507 | goto free_ep; | 509 | goto free_ep; |
508 | } | 510 | } |
509 | 511 | ||
510 | beiscsi_ep->cid_vld = 0; | 512 | beiscsi_ep->cid_vld = 0; |
511 | tag = mgmt_open_connection(phba, dst_addr, beiscsi_ep); | 513 | nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev, |
514 | sizeof(struct tcp_connect_and_offload_in), | ||
515 | &nonemb_cmd.dma); | ||
516 | if (nonemb_cmd.va == NULL) { | ||
517 | SE_DEBUG(DBG_LVL_1, | ||
518 | "Failed to allocate memory for mgmt_open_connection" | ||
519 | "\n"); | ||
520 | beiscsi_put_cid(phba, beiscsi_ep->ep_cid); | ||
521 | return -ENOMEM; | ||
522 | } | ||
523 | nonemb_cmd.size = sizeof(struct tcp_connect_and_offload_in); | ||
524 | memset(nonemb_cmd.va, 0, nonemb_cmd.size); | ||
525 | tag = mgmt_open_connection(phba, dst_addr, beiscsi_ep, &nonemb_cmd); | ||
512 | if (!tag) { | 526 | if (!tag) { |
513 | SE_DEBUG(DBG_LVL_1, | 527 | SE_DEBUG(DBG_LVL_1, |
514 | "mgmt_open_connection Failed for cid=%d\n", | 528 | "mgmt_open_connection Failed for cid=%d\n", |
515 | beiscsi_ep->ep_cid); | 529 | beiscsi_ep->ep_cid); |
516 | beiscsi_put_cid(phba, beiscsi_ep->ep_cid); | 530 | beiscsi_put_cid(phba, beiscsi_ep->ep_cid); |
531 | pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, | ||
532 | nonemb_cmd.va, nonemb_cmd.dma); | ||
517 | return -EAGAIN; | 533 | return -EAGAIN; |
518 | } else { | 534 | } else { |
519 | wait_event_interruptible(phba->ctrl.mcc_wait[tag], | 535 | wait_event_interruptible(phba->ctrl.mcc_wait[tag], |
@@ -526,7 +542,10 @@ static int beiscsi_open_conn(struct iscsi_endpoint *ep, | |||
526 | SE_DEBUG(DBG_LVL_1, "mgmt_open_connection Failed" | 542 | SE_DEBUG(DBG_LVL_1, "mgmt_open_connection Failed" |
527 | " status = %d extd_status = %d\n", | 543 | " status = %d extd_status = %d\n", |
528 | status, extd_status); | 544 | status, extd_status); |
545 | beiscsi_put_cid(phba, beiscsi_ep->ep_cid); | ||
529 | free_mcc_tag(&phba->ctrl, tag); | 546 | free_mcc_tag(&phba->ctrl, tag); |
547 | pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, | ||
548 | nonemb_cmd.va, nonemb_cmd.dma); | ||
530 | goto free_ep; | 549 | goto free_ep; |
531 | } else { | 550 | } else { |
532 | wrb = queue_get_wrb(mccq, wrb_num); | 551 | wrb = queue_get_wrb(mccq, wrb_num); |
@@ -538,6 +557,9 @@ static int beiscsi_open_conn(struct iscsi_endpoint *ep, | |||
538 | beiscsi_ep->cid_vld = 1; | 557 | beiscsi_ep->cid_vld = 1; |
539 | SE_DEBUG(DBG_LVL_8, "mgmt_open_connection Success\n"); | 558 | SE_DEBUG(DBG_LVL_8, "mgmt_open_connection Success\n"); |
540 | } | 559 | } |
560 | beiscsi_put_cid(phba, beiscsi_ep->ep_cid); | ||
561 | pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, | ||
562 | nonemb_cmd.va, nonemb_cmd.dma); | ||
541 | return 0; | 563 | return 0; |
542 | 564 | ||
543 | free_ep: | 565 | free_ep: |