Commit deeea8ed authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Martin K. Petersen

scsi: be2iscsi: Fix error return code

We know that 'ret' is not an error code because it has been tested a few
lines above.  So, if one of these function fails, 0 will be returned
instead of an error code.  Return -ENOMEM instead.
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>

'ret' needs to be set with error code if hba_setup_cid_tbls fails.
Signed-off-by: default avatarJitendra Bhivare <jitendra.bhivare@broadcom.com>
Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 51f9039f
...@@ -3017,8 +3017,8 @@ static int be_fill_queue(struct be_queue_info *q, ...@@ -3017,8 +3017,8 @@ static int be_fill_queue(struct be_queue_info *q,
static int beiscsi_create_eqs(struct beiscsi_hba *phba, static int beiscsi_create_eqs(struct beiscsi_hba *phba,
struct hwi_context_memory *phwi_context) struct hwi_context_memory *phwi_context)
{ {
int ret = -ENOMEM, eq_for_mcc;
unsigned int i, num_eq_pages; unsigned int i, num_eq_pages;
int ret = 0, eq_for_mcc;
struct be_queue_info *eq; struct be_queue_info *eq;
struct be_dma_mem *mem; struct be_dma_mem *mem;
void *eq_vaddress; void *eq_vaddress;
...@@ -3065,6 +3065,7 @@ static int beiscsi_create_eqs(struct beiscsi_hba *phba, ...@@ -3065,6 +3065,7 @@ static int beiscsi_create_eqs(struct beiscsi_hba *phba,
phwi_context->be_eq[i].q.id); phwi_context->be_eq[i].q.id);
} }
return 0; return 0;
create_eq_error: create_eq_error:
for (i = 0; i < (phba->num_cpus + eq_for_mcc); i++) { for (i = 0; i < (phba->num_cpus + eq_for_mcc); i++) {
eq = &phwi_context->be_eq[i].q; eq = &phwi_context->be_eq[i].q;
...@@ -3081,11 +3082,11 @@ static int beiscsi_create_cqs(struct beiscsi_hba *phba, ...@@ -3081,11 +3082,11 @@ static int beiscsi_create_cqs(struct beiscsi_hba *phba,
struct hwi_context_memory *phwi_context) struct hwi_context_memory *phwi_context)
{ {
unsigned int i, num_cq_pages; unsigned int i, num_cq_pages;
int ret = 0;
struct be_queue_info *cq, *eq; struct be_queue_info *cq, *eq;
struct be_dma_mem *mem; struct be_dma_mem *mem;
struct be_eq_obj *pbe_eq; struct be_eq_obj *pbe_eq;
void *cq_vaddress; void *cq_vaddress;
int ret = -ENOMEM;
dma_addr_t paddr; dma_addr_t paddr;
num_cq_pages = PAGES_REQUIRED(phba->params.num_cq_entries * \ num_cq_pages = PAGES_REQUIRED(phba->params.num_cq_entries * \
...@@ -3103,6 +3104,7 @@ static int beiscsi_create_cqs(struct beiscsi_hba *phba, ...@@ -3103,6 +3104,7 @@ static int beiscsi_create_cqs(struct beiscsi_hba *phba,
&paddr); &paddr);
if (!cq_vaddress) if (!cq_vaddress)
goto create_cq_error; goto create_cq_error;
ret = be_fill_queue(cq, phba->params.num_cq_entries, ret = be_fill_queue(cq, phba->params.num_cq_entries,
sizeof(struct sol_cqe), cq_vaddress); sizeof(struct sol_cqe), cq_vaddress);
if (ret) { if (ret) {
...@@ -3137,7 +3139,6 @@ static int beiscsi_create_cqs(struct beiscsi_hba *phba, ...@@ -3137,7 +3139,6 @@ static int beiscsi_create_cqs(struct beiscsi_hba *phba,
mem->va, mem->dma); mem->va, mem->dma);
} }
return ret; return ret;
} }
static int static int
...@@ -4230,7 +4231,8 @@ static int beiscsi_init_port(struct beiscsi_hba *phba) ...@@ -4230,7 +4231,8 @@ static int beiscsi_init_port(struct beiscsi_hba *phba)
goto do_cleanup_ctrlr; goto do_cleanup_ctrlr;
} }
if (hba_setup_cid_tbls(phba)) { ret = hba_setup_cid_tbls(phba);
if (ret < 0) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
"BM_%d : Failed in hba_setup_cid_tbls\n"); "BM_%d : Failed in hba_setup_cid_tbls\n");
kfree(phba->io_sgl_hndl_base); kfree(phba->io_sgl_hndl_base);
...@@ -5627,7 +5629,7 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev, ...@@ -5627,7 +5629,7 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
struct hwi_context_memory *phwi_context; struct hwi_context_memory *phwi_context;
struct be_eq_obj *pbe_eq; struct be_eq_obj *pbe_eq;
unsigned int s_handle; unsigned int s_handle;
int ret = 0, i; int ret, i;
ret = beiscsi_enable_pci(pcidev); ret = beiscsi_enable_pci(pcidev);
if (ret < 0) { if (ret < 0) {
...@@ -5640,6 +5642,7 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev, ...@@ -5640,6 +5642,7 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
if (!phba) { if (!phba) {
dev_err(&pcidev->dev, dev_err(&pcidev->dev,
"beiscsi_dev_probe - Failed in beiscsi_hba_alloc\n"); "beiscsi_dev_probe - Failed in beiscsi_hba_alloc\n");
ret = -ENOMEM;
goto disable_pci; goto disable_pci;
} }
...@@ -5744,6 +5747,7 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev, ...@@ -5744,6 +5747,7 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
"BM_%d : beiscsi_dev_probe-" "BM_%d : beiscsi_dev_probe-"
"Failed to allocate work queue\n"); "Failed to allocate work queue\n");
ret = -ENOMEM;
goto free_twq; goto free_twq;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment