Skip to contentSkip to conversation

sfc: check for allocation failure

PATCH Superseded Dan Carpenter 3 participants 7 messages Sep 2, 2013 – Sep 4, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sfc: check for allocation failure

It upsets static analyzers when we don't check for allocation failure.

drivers/net/ethernet/sfc/mtd.c +2 -0
index ba6c87a..aac6897 100644
@@ -384,6 +384,8 @@ static int falcon_mtd_probe(struct efx_nic *efx)
 
 	/* Allocate space for maximum number of partitions */
 	parts = kcalloc(2, sizeof(*parts), GFP_KERNEL);
+	if (!parts)
+		return -ENOMEM;
 	n_parts = 0;
 
 	spi = &nic_data->spi_flash;
Acked-by on v1 1/1
#1 lore raw
Quoted 3 lines · Dan Carpenter

It upsets static analyzers when we don't check for allocation failure.

Thanks Dan.

Ben.

Quoted 13 lines
drivers/net/ethernet/sfc/mtd.c +2 -0
index ba6c87a..aac6897 100644
@@ -384,6 +384,8 @@ static int falcon_mtd_probe(struct efx_nic *efx)
 
 	/* Allocate space for maximum number of partitions */
 	parts = kcalloc(2, sizeof(*parts), GFP_KERNEL);
+	if (!parts)
+		return -ENOMEM;
 	n_parts = 0;
 
 	spi = &nic_data->spi_flash;
Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#3 lore raw
Quoted 9 lines · David Miller

From: Dan Carpenter <[email protected]>
Date: Mon, 2 Sep 2013 12:04:42 +0300

Quoted 3 lines

It upsets static analyzers when we don't check for allocation failure.

This applies cleanly neither to net nor net-next, please send me a version that does.

Oh yes, I failed to spot the filename. That function has since been moved to falcon.c.

Ben.

Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#4 lore raw

PATCH v2 1/1 sfc: check for allocation failure

In reply to David Miller

It upsets static analyzers when we don't check for allocation failure.

---
v2: rebased on latest linux-next

drivers/net/ethernet/sfc/falcon.c +2 -0
index 38d179c..75799f8 100644
@@ -894,6 +894,8 @@ static int falcon_mtd_probe(struct efx_nic *efx)
 
 	/* Allocate space for maximum number of partitions */
 	parts = kcalloc(2, sizeof(*parts), GFP_KERNEL);
+	if (!parts)
+		return -ENOMEM;
 	n_parts = 0;
 
 	spi = &nic_data->spi_flash;
Acked-by on v2 1/1
#5 lore raw
Quoted 3 lines · Dan Carpenter

It upsets static analyzers when we don't check for allocation failure.

Quoted 16 lines

---
v2: rebased on latest linux-next

drivers/net/ethernet/sfc/falcon.c +2 -0
index 38d179c..75799f8 100644
@@ -894,6 +894,8 @@ static int falcon_mtd_probe(struct efx_nic *efx)
 
 	/* Allocate space for maximum number of partitions */
 	parts = kcalloc(2, sizeof(*parts), GFP_KERNEL);
+	if (!parts)
+		return -ENOMEM;
 	n_parts = 0;
 
 	spi = &nic_data->spi_flash;
Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.