diff options
author | Prasanna Mumbai <prasanna.mumbai@qlogic.com> | 2010-07-10 05:19:38 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2010-07-27 13:04:34 -0400 |
commit | beabe7c18338a5112fbca9a6dbcc921f9cce6325 (patch) | |
tree | 288d2d2e9013ff073ddd135e991eaced74b21887 /drivers/scsi/qla4xxx | |
parent | b966346c344f592c8e6a84c9c274a7dedbc057ad (diff) |
[SCSI] qla4xxx: Fix the freeing of the buffer allocated for DMA
Fixed the DMA allocated memory freeing which wasn't taken care
in many cases.
Signed-off-by: Prasanna Mumbai <prasanna.mumbai@qlogic.com>
Signed-off-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com>
Signed-off-by: Ravi Anand <ravi.anand@qlogic.com>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/qla4xxx')
-rw-r--r-- | drivers/scsi/qla4xxx/ql4_init.c | 38 | ||||
-rw-r--r-- | drivers/scsi/qla4xxx/ql4_mbx.c | 15 |
2 files changed, 32 insertions, 21 deletions
diff --git a/drivers/scsi/qla4xxx/ql4_init.c b/drivers/scsi/qla4xxx/ql4_init.c index d5254054b2c8..4a332c32d71e 100644 --- a/drivers/scsi/qla4xxx/ql4_init.c +++ b/drivers/scsi/qla4xxx/ql4_init.c | |||
@@ -444,17 +444,17 @@ static struct ddb_entry* qla4xxx_get_ddb_entry(struct scsi_qla_host *ha, | |||
444 | if (fw_ddb_entry == NULL) { | 444 | if (fw_ddb_entry == NULL) { |
445 | DEBUG2(printk("scsi%ld: %s: Unable to allocate dma buffer.\n", | 445 | DEBUG2(printk("scsi%ld: %s: Unable to allocate dma buffer.\n", |
446 | ha->host_no, __func__)); | 446 | ha->host_no, __func__)); |
447 | return NULL; | 447 | goto exit_get_ddb_entry_no_free; |
448 | } | 448 | } |
449 | 449 | ||
450 | if (qla4xxx_get_fwddb_entry(ha, fw_ddb_index, fw_ddb_entry, | 450 | if (qla4xxx_get_fwddb_entry(ha, fw_ddb_index, fw_ddb_entry, |
451 | fw_ddb_entry_dma, NULL, NULL, | 451 | fw_ddb_entry_dma, NULL, NULL, |
452 | &device_state, NULL, NULL, NULL) == | 452 | &device_state, NULL, NULL, NULL) == |
453 | QLA_ERROR) { | 453 | QLA_ERROR) { |
454 | DEBUG2(printk("scsi%ld: %s: failed get_ddb_entry for " | 454 | DEBUG2(printk("scsi%ld: %s: failed get_ddb_entry for " |
455 | "fw_ddb_index %d\n", ha->host_no, __func__, | 455 | "fw_ddb_index %d\n", ha->host_no, __func__, |
456 | fw_ddb_index)); | 456 | fw_ddb_index)); |
457 | return NULL; | 457 | goto exit_get_ddb_entry; |
458 | } | 458 | } |
459 | 459 | ||
460 | /* Allocate DDB if not already allocated. */ | 460 | /* Allocate DDB if not already allocated. */ |
@@ -472,6 +472,7 @@ static struct ddb_entry* qla4xxx_get_ddb_entry(struct scsi_qla_host *ha, | |||
472 | } | 472 | } |
473 | } | 473 | } |
474 | 474 | ||
475 | /* if not found allocate new ddb */ | ||
475 | if (!found) { | 476 | if (!found) { |
476 | DEBUG2(printk("scsi%ld: %s: ddb[%d] not found - allocating " | 477 | DEBUG2(printk("scsi%ld: %s: ddb[%d] not found - allocating " |
477 | "new ddb\n", ha->host_no, __func__, | 478 | "new ddb\n", ha->host_no, __func__, |
@@ -480,10 +481,11 @@ static struct ddb_entry* qla4xxx_get_ddb_entry(struct scsi_qla_host *ha, | |||
480 | ddb_entry = qla4xxx_alloc_ddb(ha, fw_ddb_index); | 481 | ddb_entry = qla4xxx_alloc_ddb(ha, fw_ddb_index); |
481 | } | 482 | } |
482 | 483 | ||
483 | /* if not found allocate new ddb */ | 484 | exit_get_ddb_entry: |
484 | dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), fw_ddb_entry, | 485 | dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), fw_ddb_entry, |
485 | fw_ddb_entry_dma); | 486 | fw_ddb_entry_dma); |
486 | 487 | ||
488 | exit_get_ddb_entry_no_free: | ||
487 | return ddb_entry; | 489 | return ddb_entry; |
488 | } | 490 | } |
489 | 491 | ||
@@ -511,7 +513,8 @@ static int qla4xxx_update_ddb_entry(struct scsi_qla_host *ha, | |||
511 | if (ddb_entry == NULL) { | 513 | if (ddb_entry == NULL) { |
512 | DEBUG2(printk("scsi%ld: %s: ddb_entry is NULL\n", ha->host_no, | 514 | DEBUG2(printk("scsi%ld: %s: ddb_entry is NULL\n", ha->host_no, |
513 | __func__)); | 515 | __func__)); |
514 | goto exit_update_ddb; | 516 | |
517 | goto exit_update_ddb_no_free; | ||
515 | } | 518 | } |
516 | 519 | ||
517 | /* Make sure the dma buffer is valid */ | 520 | /* Make sure the dma buffer is valid */ |
@@ -522,7 +525,7 @@ static int qla4xxx_update_ddb_entry(struct scsi_qla_host *ha, | |||
522 | DEBUG2(printk("scsi%ld: %s: Unable to allocate dma buffer.\n", | 525 | DEBUG2(printk("scsi%ld: %s: Unable to allocate dma buffer.\n", |
523 | ha->host_no, __func__)); | 526 | ha->host_no, __func__)); |
524 | 527 | ||
525 | goto exit_update_ddb; | 528 | goto exit_update_ddb_no_free; |
526 | } | 529 | } |
527 | 530 | ||
528 | if (qla4xxx_get_fwddb_entry(ha, fw_ddb_index, fw_ddb_entry, | 531 | if (qla4xxx_get_fwddb_entry(ha, fw_ddb_index, fw_ddb_entry, |
@@ -530,7 +533,7 @@ static int qla4xxx_update_ddb_entry(struct scsi_qla_host *ha, | |||
530 | &ddb_entry->fw_ddb_device_state, &conn_err, | 533 | &ddb_entry->fw_ddb_device_state, &conn_err, |
531 | &ddb_entry->tcp_source_port_num, | 534 | &ddb_entry->tcp_source_port_num, |
532 | &ddb_entry->connection_id) == | 535 | &ddb_entry->connection_id) == |
533 | QLA_ERROR) { | 536 | QLA_ERROR) { |
534 | DEBUG2(printk("scsi%ld: %s: failed get_ddb_entry for " | 537 | DEBUG2(printk("scsi%ld: %s: failed get_ddb_entry for " |
535 | "fw_ddb_index %d\n", ha->host_no, __func__, | 538 | "fw_ddb_index %d\n", ha->host_no, __func__, |
536 | fw_ddb_index)); | 539 | fw_ddb_index)); |
@@ -605,6 +608,7 @@ exit_update_ddb: | |||
605 | dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), | 608 | dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), |
606 | fw_ddb_entry, fw_ddb_entry_dma); | 609 | fw_ddb_entry, fw_ddb_entry_dma); |
607 | 610 | ||
611 | exit_update_ddb_no_free: | ||
608 | return status; | 612 | return status; |
609 | } | 613 | } |
610 | 614 | ||
@@ -689,7 +693,7 @@ int qla4_is_relogin_allowed(struct scsi_qla_host *ha, uint32_t conn_err) | |||
689 | **/ | 693 | **/ |
690 | static int qla4xxx_build_ddb_list(struct scsi_qla_host *ha) | 694 | static int qla4xxx_build_ddb_list(struct scsi_qla_host *ha) |
691 | { | 695 | { |
692 | int status = QLA_SUCCESS; | 696 | int status = QLA_ERROR; |
693 | uint32_t fw_ddb_index = 0; | 697 | uint32_t fw_ddb_index = 0; |
694 | uint32_t next_fw_ddb_index = 0; | 698 | uint32_t next_fw_ddb_index = 0; |
695 | uint32_t ddb_state; | 699 | uint32_t ddb_state; |
@@ -705,7 +709,8 @@ static int qla4xxx_build_ddb_list(struct scsi_qla_host *ha) | |||
705 | if (fw_ddb_entry == NULL) { | 709 | if (fw_ddb_entry == NULL) { |
706 | DEBUG2(dev_info(&ha->pdev->dev, "%s: DMA alloc failed\n", | 710 | DEBUG2(dev_info(&ha->pdev->dev, "%s: DMA alloc failed\n", |
707 | __func__)); | 711 | __func__)); |
708 | return QLA_ERROR; | 712 | |
713 | goto exit_build_ddb_list_no_free; | ||
709 | } | 714 | } |
710 | 715 | ||
711 | dev_info(&ha->pdev->dev, "Initializing DDBs ...\n"); | 716 | dev_info(&ha->pdev->dev, "Initializing DDBs ...\n"); |
@@ -720,7 +725,7 @@ static int qla4xxx_build_ddb_list(struct scsi_qla_host *ha) | |||
720 | DEBUG2(printk("scsi%ld: %s: get_ddb_entry, " | 725 | DEBUG2(printk("scsi%ld: %s: get_ddb_entry, " |
721 | "fw_ddb_index %d failed", ha->host_no, | 726 | "fw_ddb_index %d failed", ha->host_no, |
722 | __func__, fw_ddb_index)); | 727 | __func__, fw_ddb_index)); |
723 | return QLA_ERROR; | 728 | goto exit_build_ddb_list; |
724 | } | 729 | } |
725 | 730 | ||
726 | DEBUG2(printk("scsi%ld: %s: Getting DDB[%d] ddbstate=0x%x, " | 731 | DEBUG2(printk("scsi%ld: %s: Getting DDB[%d] ddbstate=0x%x, " |
@@ -750,7 +755,7 @@ static int qla4xxx_build_ddb_list(struct scsi_qla_host *ha) | |||
750 | "get_ddb_entry %d failed\n", | 755 | "get_ddb_entry %d failed\n", |
751 | ha->host_no, | 756 | ha->host_no, |
752 | __func__, fw_ddb_index)); | 757 | __func__, fw_ddb_index)); |
753 | return QLA_ERROR; | 758 | goto exit_build_ddb_list; |
754 | } | 759 | } |
755 | } | 760 | } |
756 | } | 761 | } |
@@ -770,7 +775,7 @@ static int qla4xxx_build_ddb_list(struct scsi_qla_host *ha) | |||
770 | DEBUG2(printk("scsi%ld: %s: Unable to allocate memory " | 775 | DEBUG2(printk("scsi%ld: %s: Unable to allocate memory " |
771 | "for device at fw_ddb_index %d\n", | 776 | "for device at fw_ddb_index %d\n", |
772 | ha->host_no, __func__, fw_ddb_index)); | 777 | ha->host_no, __func__, fw_ddb_index)); |
773 | return QLA_ERROR; | 778 | goto exit_build_ddb_list; |
774 | } | 779 | } |
775 | /* Fill in the device structure */ | 780 | /* Fill in the device structure */ |
776 | if (qla4xxx_update_ddb_entry(ha, ddb_entry, fw_ddb_index) == | 781 | if (qla4xxx_update_ddb_entry(ha, ddb_entry, fw_ddb_index) == |
@@ -778,11 +783,10 @@ static int qla4xxx_build_ddb_list(struct scsi_qla_host *ha) | |||
778 | ha->fw_ddb_index_map[fw_ddb_index] = | 783 | ha->fw_ddb_index_map[fw_ddb_index] = |
779 | (struct ddb_entry *)INVALID_ENTRY; | 784 | (struct ddb_entry *)INVALID_ENTRY; |
780 | 785 | ||
781 | |||
782 | DEBUG2(printk("scsi%ld: %s: update_ddb_entry failed " | 786 | DEBUG2(printk("scsi%ld: %s: update_ddb_entry failed " |
783 | "for fw_ddb_index %d.\n", | 787 | "for fw_ddb_index %d.\n", |
784 | ha->host_no, __func__, fw_ddb_index)); | 788 | ha->host_no, __func__, fw_ddb_index)); |
785 | return QLA_ERROR; | 789 | goto exit_build_ddb_list; |
786 | } | 790 | } |
787 | 791 | ||
788 | next_one: | 792 | next_one: |
@@ -792,8 +796,14 @@ next_one: | |||
792 | break; | 796 | break; |
793 | } | 797 | } |
794 | 798 | ||
799 | status = QLA_SUCCESS; | ||
795 | dev_info(&ha->pdev->dev, "DDB list done..\n"); | 800 | dev_info(&ha->pdev->dev, "DDB list done..\n"); |
796 | 801 | ||
802 | exit_build_ddb_list: | ||
803 | dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), fw_ddb_entry, | ||
804 | fw_ddb_entry_dma); | ||
805 | |||
806 | exit_build_ddb_list_no_free: | ||
797 | return status; | 807 | return status; |
798 | } | 808 | } |
799 | 809 | ||
diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c index 75496fb0ae75..54db6cbbd942 100644 --- a/drivers/scsi/qla4xxx/ql4_mbx.c +++ b/drivers/scsi/qla4xxx/ql4_mbx.c | |||
@@ -317,7 +317,7 @@ int qla4xxx_initialize_fw_cb(struct scsi_qla_host * ha) | |||
317 | if (init_fw_cb == NULL) { | 317 | if (init_fw_cb == NULL) { |
318 | DEBUG2(printk("scsi%ld: %s: Unable to alloc init_cb\n", | 318 | DEBUG2(printk("scsi%ld: %s: Unable to alloc init_cb\n", |
319 | ha->host_no, __func__)); | 319 | ha->host_no, __func__)); |
320 | return 10; | 320 | goto exit_init_fw_cb_no_free; |
321 | } | 321 | } |
322 | memset(init_fw_cb, 0, sizeof(struct addr_ctrl_blk)); | 322 | memset(init_fw_cb, 0, sizeof(struct addr_ctrl_blk)); |
323 | 323 | ||
@@ -373,7 +373,7 @@ int qla4xxx_initialize_fw_cb(struct scsi_qla_host * ha) | |||
373 | exit_init_fw_cb: | 373 | exit_init_fw_cb: |
374 | dma_free_coherent(&ha->pdev->dev, sizeof(struct addr_ctrl_blk), | 374 | dma_free_coherent(&ha->pdev->dev, sizeof(struct addr_ctrl_blk), |
375 | init_fw_cb, init_fw_cb_dma); | 375 | init_fw_cb, init_fw_cb_dma); |
376 | 376 | exit_init_fw_cb_no_free: | |
377 | return status; | 377 | return status; |
378 | } | 378 | } |
379 | 379 | ||
@@ -394,7 +394,7 @@ int qla4xxx_get_dhcp_ip_address(struct scsi_qla_host * ha) | |||
394 | if (init_fw_cb == NULL) { | 394 | if (init_fw_cb == NULL) { |
395 | printk("scsi%ld: %s: Unable to alloc init_cb\n", ha->host_no, | 395 | printk("scsi%ld: %s: Unable to alloc init_cb\n", ha->host_no, |
396 | __func__); | 396 | __func__); |
397 | return 10; | 397 | return QLA_ERROR; |
398 | } | 398 | } |
399 | 399 | ||
400 | /* Get Initialize Firmware Control Block. */ | 400 | /* Get Initialize Firmware Control Block. */ |
@@ -1019,16 +1019,16 @@ int qla4xxx_send_tgts(struct scsi_qla_host *ha, char *ip, uint16_t port) | |||
1019 | DEBUG2(printk("scsi%ld: %s: Unable to allocate dma buffer.\n", | 1019 | DEBUG2(printk("scsi%ld: %s: Unable to allocate dma buffer.\n", |
1020 | ha->host_no, __func__)); | 1020 | ha->host_no, __func__)); |
1021 | ret_val = QLA_ERROR; | 1021 | ret_val = QLA_ERROR; |
1022 | goto qla4xxx_send_tgts_exit; | 1022 | goto exit_send_tgts_no_free; |
1023 | } | 1023 | } |
1024 | 1024 | ||
1025 | ret_val = qla4xxx_get_default_ddb(ha, fw_ddb_entry_dma); | 1025 | ret_val = qla4xxx_get_default_ddb(ha, fw_ddb_entry_dma); |
1026 | if (ret_val != QLA_SUCCESS) | 1026 | if (ret_val != QLA_SUCCESS) |
1027 | goto qla4xxx_send_tgts_exit; | 1027 | goto exit_send_tgts; |
1028 | 1028 | ||
1029 | ret_val = qla4xxx_req_ddb_entry(ha, &ddb_index); | 1029 | ret_val = qla4xxx_req_ddb_entry(ha, &ddb_index); |
1030 | if (ret_val != QLA_SUCCESS) | 1030 | if (ret_val != QLA_SUCCESS) |
1031 | goto qla4xxx_send_tgts_exit; | 1031 | goto exit_send_tgts; |
1032 | 1032 | ||
1033 | memset(fw_ddb_entry->iscsi_alias, 0, | 1033 | memset(fw_ddb_entry->iscsi_alias, 0, |
1034 | sizeof(fw_ddb_entry->iscsi_alias)); | 1034 | sizeof(fw_ddb_entry->iscsi_alias)); |
@@ -1050,9 +1050,10 @@ int qla4xxx_send_tgts(struct scsi_qla_host *ha, char *ip, uint16_t port) | |||
1050 | 1050 | ||
1051 | ret_val = qla4xxx_set_ddb_entry(ha, ddb_index, fw_ddb_entry_dma); | 1051 | ret_val = qla4xxx_set_ddb_entry(ha, ddb_index, fw_ddb_entry_dma); |
1052 | 1052 | ||
1053 | qla4xxx_send_tgts_exit: | 1053 | exit_send_tgts: |
1054 | dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), | 1054 | dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), |
1055 | fw_ddb_entry, fw_ddb_entry_dma); | 1055 | fw_ddb_entry, fw_ddb_entry_dma); |
1056 | exit_send_tgts_no_free: | ||
1056 | return ret_val; | 1057 | return ret_val; |
1057 | } | 1058 | } |
1058 | 1059 | ||