Skip to contentSkip to conversation

mpt2sas: add missing allocation check

PATCH In review Tomas Henzl 2 participants 2 messages Feb 13, 2012 – Feb 14, 2012 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mpt2sas: add missing allocation check

The __get_free_pages can fail, so the return value should be checked. Spotted thanks to Stanislaw.

drivers/scsi/mpt2sas/mpt2sas_base.c +5 -0
index 0b2c955..590e1a1 100644
@@ -2575,6 +2575,11 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc,  int sleep_flag)
 
 	ioc->chain_lookup = (struct chain_tracker *)__get_free_pages(
 	    GFP_KERNEL, ioc->chain_pages);
+	if (!ioc->chain_lookup) {
+		printk(MPT2SAS_ERR_FMT "chain_lookup: get_free_pages failed, "
+		    "sz(%d)\n", ioc->name, (int)sz);
+		goto out;
+	}
 	ioc->chain_dma_pool = pci_pool_create("chain pool", ioc->pdev,
 	    ioc->request_sz, 16, 0);
 	if (!ioc->chain_dma_pool) {
#1 lore raw

This patch seem to be fine. Please consider this patch as Acked-by: "Nandigama, Nagalakshmi" <[email protected]>

Regards,
Nagalakshmi

-----Original Message-----
From: Tomas Henzl [mailto:[email protected]]
Sent: Monday, February 13, 2012 11:00 PM
To: '[email protected]'
Cc: Desai, Kashyap; Nandigama, Nagalakshmi; Stanislaw Gruszka
Subject: [PATCH] mpt2sas: add missing allocation check

The __get_free_pages can fail, so the return value should be checked. Spotted thanks to Stanislaw.

drivers/scsi/mpt2sas/mpt2sas_base.c +5 -0
index 0b2c955..590e1a1 100644
@@ -2575,6 +2575,11 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc,  int sleep_flag)
 
 	ioc->chain_lookup = (struct chain_tracker *)__get_free_pages(
 	    GFP_KERNEL, ioc->chain_pages);
+	if (!ioc->chain_lookup) {
+		printk(MPT2SAS_ERR_FMT "chain_lookup: get_free_pages failed, "
+		    "sz(%d)\n", ioc->name, (int)sz);
+		goto out;
+	}
 	ioc->chain_dma_pool = pci_pool_create("chain pool", ioc->pdev,
 	    ioc->request_sz, 16, 0);
 	if (!ioc->chain_dma_pool) {