Re: [PATCH v2 1/3] be2iscsi: Fix error return code

2016-08-26 Thread Johannes Thumshirn
On Fri, Aug 26, 2016 at 03:09:06PM +0530, Jitendra Bhivare wrote:
> From: Christophe JAILLET 
> 
> 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: Christophe JAILLET 
> 
> 'ret' needs to be set with error code if hba_setup_cid_tbls fails.
> 
> Signed-off-by: Jitendra Bhivare 
> ---

Reviewed-by: Johannes Thumshirn 

-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/3] be2iscsi: Fix error return code

2016-08-26 Thread Jitendra Bhivare
From: Christophe JAILLET 

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: Christophe JAILLET 

'ret' needs to be set with error code if hba_setup_cid_tbls fails.

Signed-off-by: Jitendra Bhivare 
---
 drivers/scsi/be2iscsi/be_main.c | 22 +-
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 222edfc..b30db87 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -3017,8 +3017,8 @@ static int be_fill_queue(struct be_queue_info *q,
 static int beiscsi_create_eqs(struct beiscsi_hba *phba,
 struct hwi_context_memory *phwi_context)
 {
+   int ret = -ENOMEM, eq_for_mcc;
unsigned int i, num_eq_pages;
-   int ret = 0, eq_for_mcc;
struct be_queue_info *eq;
struct be_dma_mem *mem;
void *eq_vaddress;
@@ -3036,8 +3036,8 @@ static int beiscsi_create_eqs(struct beiscsi_hba *phba,
mem = >dma_mem;
phwi_context->be_eq[i].phba = phba;
eq_vaddress = pci_alloc_consistent(phba->pcidev,
-num_eq_pages * PAGE_SIZE,
-);
+  num_eq_pages * PAGE_SIZE,
+  );
if (!eq_vaddress)
goto create_eq_error;
 
@@ -3065,6 +3065,7 @@ static int beiscsi_create_eqs(struct beiscsi_hba *phba,
phwi_context->be_eq[i].q.id);
}
return 0;
+
 create_eq_error:
for (i = 0; i < (phba->num_cpus + eq_for_mcc); i++) {
eq = _context->be_eq[i].q;
@@ -3081,11 +3082,11 @@ static int beiscsi_create_cqs(struct beiscsi_hba *phba,
 struct hwi_context_memory *phwi_context)
 {
unsigned int i, num_cq_pages;
-   int ret = 0;
struct be_queue_info *cq, *eq;
struct be_dma_mem *mem;
struct be_eq_obj *pbe_eq;
void *cq_vaddress;
+   int ret = -ENOMEM;
dma_addr_t paddr;
 
num_cq_pages = PAGES_REQUIRED(phba->params.num_cq_entries * \
@@ -3099,10 +3100,11 @@ static int beiscsi_create_cqs(struct beiscsi_hba *phba,
pbe_eq->phba = phba;
mem = >dma_mem;
cq_vaddress = pci_alloc_consistent(phba->pcidev,
-num_cq_pages * PAGE_SIZE,
-);
+  num_cq_pages * PAGE_SIZE,
+  );
if (!cq_vaddress)
goto create_cq_error;
+
ret = be_fill_queue(cq, phba->params.num_cq_entries,
sizeof(struct sol_cqe), cq_vaddress);
if (ret) {
@@ -3137,7 +3139,6 @@ create_cq_error:
mem->va, mem->dma);
}
return ret;
-
 }
 
 static int
@@ -4230,7 +4231,8 @@ static int beiscsi_init_port(struct beiscsi_hba *phba)
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,
"BM_%d : Failed in hba_setup_cid_tbls\n");
kfree(phba->io_sgl_hndl_base);
@@ -5627,7 +5629,7 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
struct hwi_context_memory *phwi_context;
struct be_eq_obj *pbe_eq;
unsigned int s_handle;
-   int ret = 0, i;
+   int ret, i;
 
ret = beiscsi_enable_pci(pcidev);
if (ret < 0) {
@@ -5640,6 +5642,7 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
if (!phba) {
dev_err(>dev,
"beiscsi_dev_probe - Failed in beiscsi_hba_alloc\n");
+   ret = -ENOMEM;
goto disable_pci;
}
 
@@ -5744,6 +5747,7 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev,
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
"BM_%d : beiscsi_dev_probe-"
"Failed to allocate work queue\n");
+   ret = -ENOMEM;
goto free_twq;
}
 
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html