Skip to contentSkip to conversation

staging: altera-stapl: fix memory leaks

PATCH In review Alexander Beregalov 2 participants 9 messages Mar 10, 2011 – Mar 13, 2011 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/6 staging: altera-stapl: fix memory leaks

Free resources before exit.

---
 drivers/staging/altera-stapl/altera.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
drivers/staging/altera-stapl/altera.c +7 -2
index 05aad35..fcc7650 100644
@@ -2435,11 +2435,16 @@ int altera_init(struct altera_config *config, const struct firmware *fw)
 	if (!key)
 		return -ENOMEM;
 	value = kzalloc(257 * sizeof(char), GFP_KERNEL);
-	if (!value)
+	if (!value) {
+		kfree(key);
 		return -ENOMEM;
+	}
 	astate = kzalloc(sizeof(struct altera_state), GFP_KERNEL);
-	if (!astate)
+	if (!astate) {
+		kfree(value);
+		kfree(key);
 		return -ENOMEM;
+	}
 
 	astate->config = config;
 	if (!astate->config->jtag_io) {
Signature · 1 line
1.7.4.1
#1 lore raw

PATCH 2/6 staging: bcm: fix memory leaks

Free resources before exit.

---
 drivers/staging/bcm/Bcmchar.c |    1 +
 drivers/staging/bcm/CmHost.c  |   46 ++++++++++++++++++++++++++++------------
 2 files changed, 33 insertions(+), 14 deletions(-)
drivers/staging/bcm/Bcmchar.c +1 -0
index 867dbf1..0013315 100644
@@ -311,6 +311,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
 			{
 				BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "RDM Done On invalid Address : %x Access Denied.\n",
 					(int)sRdmBuffer.Register);
+				kfree(temp_buff);
 				return -EINVAL;
 			}
 
drivers/staging/bcm/CmHost.c +32 -14

84 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#2 lore raw

Re: [PATCH next 2/6] staging: bcm: fix memory leaks

Quoted 1 line · Alexander Beregalov

Free resources before exit.

Next time, test your patches before sending them out. This one breaks the build so I've dropped all of the patches in this series. Please fix them, test them (by at the very _least_ building them) and then resend them.

thanks,

greg k-h

#3 lore raw

Re: [PATCH next 2/6] staging: bcm: fix memory leaks

Quoted 7 lines · Greg KH
Quoted 1 line · Alexander Beregalov

Free resources before exit.

Next time, test your patches before sending them out.  This one breaks the build so I've dropped all of the patches in this series.  Please fix them, test them (by at the very _least_ building them) and then resend them.

Sorry for that, I have sent them again.

#4 lore raw

PATCH 3/6 staging: brcm80211: fix memory leaks

In reply to Alexander Beregalov

Free resources before exit.

---
 drivers/staging/brcm80211/brcmfmac/dhd_sdio.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +8 -4
index b74b3c6..28bc553 100644
@@ -5649,6 +5649,10 @@ static int dhdsdio_download_code_array(struct dhd_bus *bus)
 		unsigned char *ularray;
 
 		ularray = kmalloc(bus->ramsize, GFP_ATOMIC);
+		if (!ularray) {
+			bcmerror = BCME_NOMEM;
+			goto err;
+		}
 		/* Upload image to verify downloaded contents. */
 		offset = 0;
 		memset(ularray, 0xaa, bus->ramsize);
@@ -5660,7 +5664,7 @@ static int dhdsdio_download_code_array(struct dhd_bus *bus)
 				DHD_ERROR(("%s: error %d on reading %d membytes"
 					" at 0x%08x\n",
 					__func__, bcmerror, MEMBLOCK, offset));
-				goto err;
+				goto free;
 			}
 
 			offset += MEMBLOCK;
@@ -5674,7 +5678,7 @@ static int dhdsdio_download_code_array(struct dhd_bus *bus)
 				DHD_ERROR(("%s: error %d on reading %d membytes at 0x%08x\n",
 				__func__, bcmerror,
 				sizeof(dlarray) - offset, offset));
-				goto err;
+				goto free;
 			}
 		}
 
@@ -5682,11 +5686,11 @@ static int dhdsdio_download_code_array(struct dhd_bus *bus)
 			DHD_ERROR(("%s: Downloaded image is corrupted.\n",
 				   __func__));
 			ASSERT(0);
-			goto err;
+			goto free;
 		} else
 			DHD_ERROR(("%s: Download/Upload/Compare succeeded.\n",
 				__func__));
-
+free:
 		kfree(ularray);
 	}
 #endif				/* DHD_DEBUG */
Signature · 1 line
1.7.4.1
#5 lore raw

PATCH 4/6 staging: crystalhd: fix memory leaks

In reply to Alexander Beregalov

Free resources before exit.

---
 drivers/staging/crystalhd/crystalhd_hw.c  |    1 +
 drivers/staging/crystalhd/crystalhd_lnx.c |   18 +++++++++++++-----
 2 files changed, 14 insertions(+), 5 deletions(-)
drivers/staging/crystalhd/crystalhd_hw.c +1 -0
index 153ddbf..13a514d 100644
@@ -1965,6 +1965,7 @@ enum BC_STATUS crystalhd_hw_setup_dma_rings(struct crystalhd_hw *hw)
 		} else {
 			BCMLOG_ERR("Insufficient Memory For RX\n");
 			crystalhd_hw_free_dma_rings(hw);
+			kfree(rpkt);
 			return BC_STS_INSUFF_RES;
 		}
 		rpkt->desc_mem.pdma_desc_start = mem;
drivers/staging/crystalhd/crystalhd_lnx.c +13 -5
index 719e70b..2b47ef9 100644
@@ -561,7 +561,7 @@ static int __devinit chd_dec_pci_probe(struct pci_dev *pdev,
 	rc = pci_enable_device(pdev);
 	if (rc) {
 		BCMLOG_ERR("Failed to enable PCI device\n");
-		return rc;
+		goto err;
 	}
 
 	snprintf(pinfo->name, 31, "crystalhd_pci_e:%d:%d:%d",
@@ -572,7 +572,8 @@ static int __devinit chd_dec_pci_probe(struct pci_dev *pdev,
 	if (rc) {
 		BCMLOG_ERR("Failed to setup memory regions.\n");
 		pci_disable_device(pdev);
-		return -ENOMEM;
+		rc = -ENOMEM;
+		goto err;
 	}
 
 	pinfo->present	= 1;
@@ -587,7 +588,8 @@ static int __devinit chd_dec_pci_probe(struct pci_dev *pdev,
 	if (rc) {
 		BCMLOG_ERR("_enable_int err:%d\n", rc);
 		pci_disable_device(pdev);
-		return -ENODEV;
+		rc = -ENODEV;
+		goto err;
 	}
 
 	/* Set dma mask... */
@@ -600,14 +602,16 @@ static int __devinit chd_dec_pci_probe(struct pci_dev *pdev,
 	} else {
 		BCMLOG_ERR("Unabled to setup DMA %d\n", rc);
 		pci_disable_device(pdev);
-		return -ENODEV;
+		rc = -ENODEV;
+		goto err;
 	}
 
 	sts = crystalhd_setup_cmd_context(&pinfo->cmds, pinfo);
 	if (sts != BC_STS_SUCCESS) {
 		BCMLOG_ERR("cmd setup :%d\n", sts);
 		pci_disable_device(pdev);
-		return -ENODEV;
+		rc = -ENODEV;
+		goto err;
 	}
 
 	pci_set_master(pdev);
@@ -617,6 +621,10 @@ static int __devinit chd_dec_pci_probe(struct pci_dev *pdev,
 	g_adp_info = pinfo;
 
 	return 0;
+
+err:
+	kfree(pinfo);
+	return rc;
 }
 
 #ifdef CONFIG_PM
Signature · 1 line
1.7.4.1
#6 lore raw

PATCH 5/6 staging: hv: fix memory leaks

In reply to Alexander Beregalov

Free resources before exit.

---
 drivers/staging/hv/hv_mouse.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/staging/hv/hv_mouse.c +2 -0
index 8f94f43..954164c 100644
@@ -688,6 +688,7 @@ static int MousevscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo)
 
 	if (ret != 0) {
 		pr_err("unable to open channel: %d", ret);
+		FreeInputDevice(inputDevice);
 		return -1;
 	}
 
@@ -699,6 +700,7 @@ static int MousevscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo)
 		pr_err("unable to connect channel: %d", ret);
 
 		vmbus_close(Device->channel);
+		FreeInputDevice(inputDevice);
 		return ret;
 	}
 
Signature · 1 line
1.7.4.1
#7 lore raw

PATCH 6/6 staging: ste_rmi4: fix memory leaks

In reply to Alexander Beregalov

Free resources before exit.

---
 drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c +3 -1
index 51b4a79..d55a8e4 100644
@@ -764,8 +764,10 @@ static int synaptics_rmi4_i2c_query_device(struct synaptics_rmi4_data *pdata)
 								(pdata,	rfi,
 								&rmi_fd,
 								intr_count);
-					if (retval < 0)
+					if (retval < 0) {
+						kfree(rfi);
 						return retval;
+					}
 				}
 				break;
 			}
Signature · 1 line
1.7.4.1