scsi: be2iscsi: Fix a theoretical leak in beiscsi_create_eqs()
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 28 Sep 2020 09:13:00 +0000 (12:13 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 Oct 2020 08:07:07 +0000 (09:07 +0100)
[ Upstream commit 38b2db564d9ab7797192ef15d7aade30633ceeae ]

The be_fill_queue() function can only fail when "eq_vaddress" is NULL and
since it's non-NULL here that means the function call can't fail.  But
imagine if it could, then in that situation we would want to store the
"paddr" so that dma memory can be released.

Link: https://lore.kernel.org/r/20200928091300.GD377727@mwanda
Fixes: bfead3b2cb46 ("[SCSI] be2iscsi: Adding msix and mcc_rings V3")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/scsi/be2iscsi/be_main.c

index b4542e7e2ad5b77cb910f25554ba98d3663fb1cb..86e1eac3a4703d6c4bf9005090df115fe6c1f29d 100644 (file)
@@ -3013,6 +3013,7 @@ static int beiscsi_create_eqs(struct beiscsi_hba *phba,
                        goto create_eq_error;
                }
 
+               mem->dma = paddr;
                mem->va = eq_vaddress;
                ret = be_fill_queue(eq, phba->params.num_eq_entries,
                                    sizeof(struct be_eq_entry), eq_vaddress);
@@ -3022,7 +3023,6 @@ static int beiscsi_create_eqs(struct beiscsi_hba *phba,
                        goto create_eq_error;
                }
 
-               mem->dma = paddr;
                ret = beiscsi_cmd_eq_create(&phba->ctrl, eq,
                                            phwi_context->cur_eqd);
                if (ret) {
@@ -3079,6 +3079,7 @@ static int beiscsi_create_cqs(struct beiscsi_hba *phba,
                        goto create_cq_error;
                }
 
+               mem->dma = paddr;
                ret = be_fill_queue(cq, phba->params.num_cq_entries,
                                    sizeof(struct sol_cqe), cq_vaddress);
                if (ret) {
@@ -3088,7 +3089,6 @@ static int beiscsi_create_cqs(struct beiscsi_hba *phba,
                        goto create_cq_error;
                }
 
-               mem->dma = paddr;
                ret = beiscsi_cmd_cq_create(&phba->ctrl, cq, eq, false,
                                            false, 0);
                if (ret) {