[PATCH for v4.9 LTS 57/87] scsi: snic: Return error code on memory allocation failure

From: Levin, Alexander (Sasha Levin)
Date: Fri Jul 14 2017 - 21:42:53 EST


From: Burak Ok <burak-kernel@xxxxxxxx>

[ Upstream commit 0371adcdaca92912baaa3256ed13e058a016e62d ]

If a call to mempool_create_slab_pool() in snic_probe() returns NULL,
return -ENOMEM to indicate failure. mempool_creat_slab_pool() only fails
if it cannot allocate memory.

https://bugzilla.kernel.org/show_bug.cgi?id=189061

Reported-by: bianpan2010@xxxxxxxxxx
Signed-off-by: Burak Ok <burak-kernel@xxxxxxxx>
Signed-off-by: Andreas Schaertl <andreas.schaertl@xxxxxx>
Acked-by: Narsimhulu Musini <nmusini@xxxxxxxxx>
Reviewed-by: Ewan D. Milne <emilne@xxxxxxxxxx>
Signed-off-by: Martin K. Petersen <martin.petersen@xxxxxxxxxx>
Signed-off-by: Sasha Levin <alexander.levin@xxxxxxxxxxx>
---
drivers/scsi/snic/snic_main.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/scsi/snic/snic_main.c b/drivers/scsi/snic/snic_main.c
index 396b32dca074..7cf70aaec0ba 100644
--- a/drivers/scsi/snic/snic_main.c
+++ b/drivers/scsi/snic/snic_main.c
@@ -591,6 +591,7 @@ snic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (!pool) {
SNIC_HOST_ERR(shost, "dflt sgl pool creation failed\n");

+ ret = -ENOMEM;
goto err_free_res;
}

@@ -601,6 +602,7 @@ snic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (!pool) {
SNIC_HOST_ERR(shost, "max sgl pool creation failed\n");

+ ret = -ENOMEM;
goto err_free_dflt_sgl_pool;
}

@@ -611,6 +613,7 @@ snic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (!pool) {
SNIC_HOST_ERR(shost, "snic tmreq info pool creation failed.\n");

+ ret = -ENOMEM;
goto err_free_max_sgl_pool;
}

--
2.11.0