From patchwork Fri Aug 26 09:39:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jitendra Bhivare X-Patchwork-Id: 9301059 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 054D4607D8 for ; Fri, 26 Aug 2016 09:39:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA85B295E0 for ; Fri, 26 Aug 2016 09:39:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF33F295FE; Fri, 26 Aug 2016 09:39:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74065295E0 for ; Fri, 26 Aug 2016 09:39:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752717AbcHZJjf (ORCPT ); Fri, 26 Aug 2016 05:39:35 -0400 Received: from mail-pf0-f169.google.com ([209.85.192.169]:34498 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752371AbcHZJjc (ORCPT ); Fri, 26 Aug 2016 05:39:32 -0400 Received: by mail-pf0-f169.google.com with SMTP id p64so27184575pfb.1 for ; Fri, 26 Aug 2016 02:39:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lqQkERxsItWD8WFMwfWEjmqy8Wq8Mih8/riJ2E5o+Hw=; b=FB8Bvaxslj8Iizbs/id4FD29jX3WTEX3ZVBjc8R96DTcldkhQojuEelARRWYUn+zH+ CTaS8cW9b4JXTWIHITHKIWL5cX3fiHZSFe0I/t+Jmf2Zp+Z2LdCZUL1G55bqgzDI6Q5l 6E0o7KcGZ3HPUHi5VUdG7ShtLPJiSBfDQ6WcI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lqQkERxsItWD8WFMwfWEjmqy8Wq8Mih8/riJ2E5o+Hw=; b=idEQvkTILix71/V61OwpPl5tBAuZn5CcPDqDb1gvbUwqT3wTjKmggZclzYvLDrjWb2 rglh/f985B6ufiS0tg7JfAg1pHShNZppqiarNNlRHpQY6bya7zzCreonTqsrYojKx0AO oRCgkbD6WSWhUDsy/KBkCrM3oABwpzvVitscZUdJ2Xb+j9SeQc3i8M5sp+AlHAr1cJO6 MjT3YUqa7q6SM3Y5acYhw79bdacMVL1/kK0q5foHOnBzx00CFIIVRfAKpzRoagcBQjEs 50geUnK1FldcQJg8j5oWv0oHYl6fzQY5CT65NxHTwfKpwuvyFyWKuQntnd5Ct9lj4wYV 9i3g== X-Gm-Message-State: AE9vXwNe9Faldm2pO5nJo/CftX2mCrOVbao4OsuwMQcovONeD5FZAK6V1bYMdCGolxm158Dt X-Received: by 10.98.94.6 with SMTP id s6mr4213456pfb.31.1472204361732; Fri, 26 Aug 2016 02:39:21 -0700 (PDT) Received: from android.dhcp.avagotech.net ([192.19.239.250]) by smtp.gmail.com with ESMTPSA id ty6sm27100139pac.18.2016.08.26.02.39.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Aug 2016 02:39:21 -0700 (PDT) From: Jitendra Bhivare To: christophe.jaillet@wanadoo.fr, julia.lawall@lip6.fr, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, Jitendra Bhivare Subject: [PATCH v2 1/3] be2iscsi: Fix error return code Date: Fri, 26 Aug 2016 15:09:06 +0530 Message-Id: <1472204348-5960-2-git-send-email-jitendra.bhivare@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1472204348-5960-1-git-send-email-jitendra.bhivare@broadcom.com> References: <1472204348-5960-1-git-send-email-jitendra.bhivare@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 = &eq->dma_mem; phwi_context->be_eq[i].phba = phba; eq_vaddress = pci_alloc_consistent(phba->pcidev, - num_eq_pages * PAGE_SIZE, - &paddr); + num_eq_pages * PAGE_SIZE, + &paddr); 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 = &phwi_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 = &cq->dma_mem; cq_vaddress = pci_alloc_consistent(phba->pcidev, - num_cq_pages * PAGE_SIZE, - &paddr); + num_cq_pages * PAGE_SIZE, + &paddr); 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(&pcidev->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; }