Commit 61704c08 authored by Andrew Morton's avatar Andrew Morton Committed by Patrick Mochel

[PATCH] fix lots of error-path memory leaks

From Badari Pulavarti.

Fixes lots of error-path memleaks which the Stanford guys found.
parent 427a5f53
......@@ -1046,7 +1046,7 @@ cciss_update_non_disk_devices(int cntl_num, int hostno)
}
else {
printk(KERN_ERR "cciss: Report physical LUNs failed.\n");
return;
goto out;
}
......@@ -1091,7 +1091,7 @@ cciss_update_non_disk_devices(int cntl_num, int hostno)
}
adjust_cciss_scsi_table(cntl_num, hostno, currentsd, ncurrent);
out:
kfree(inq_buff);
kfree(ld_buff);
return;
......
......@@ -203,6 +203,7 @@ register_slot (acpi_handle handle, u32 lvl, void *context, void **rv)
if (ACPI_FAILURE(status)) {
err("failed to register interrupt notify handler\n");
kfree(newfunc);
return status;
}
......
......@@ -222,6 +222,8 @@ int isdn_x25iface_connect_ind(struct concap_proto *cprot)
printk(KERN_WARNING
"isdn_x25iface_connect_ind while unconfigured %s\n"
, MY_DEVNAME(cprot->net_dev) );
if (skb)
dev_kfree_skb(skb);
return -1;
}
*state_p = WAN_CONNECTED;
......
......@@ -1071,6 +1071,7 @@ static void pcbit_set_msn(struct pcbit_dev *dev, char *list)
ptr->msn = kmalloc(len, GFP_ATOMIC);
if (!ptr->msn) {
printk(KERN_WARNING "kmalloc failed\n");
kfree(ptr);
return;
}
......
......@@ -278,6 +278,7 @@ int dm_hash_rename(const char *old, const char *new)
DMWARN("asked to rename to an already existing name %s -> %s",
old, new);
up_write(&_hash_lock);
kfree(new_name);
return -EBUSY;
}
......@@ -289,6 +290,7 @@ int dm_hash_rename(const char *old, const char *new)
DMWARN("asked to rename a non existent device %s -> %s",
old, new);
up_write(&_hash_lock);
kfree(new_name);
return -ENXIO;
}
......
......@@ -122,6 +122,8 @@ int dm_register_target(struct target_type *t)
list_add(&ti->list, &_targets);
up_write(&_lock);
if (rv)
kfree(ti);
return rv;
}
......
......@@ -167,6 +167,7 @@ static int bt819_attach(struct i2c_adapter *adap, int addr , unsigned long flags
decoder = kmalloc(sizeof(struct bt819), GFP_KERNEL);
if (decoder == NULL) {
MOD_DEC_USE_COUNT;
kfree(client);
return -ENOMEM;
}
......
......@@ -311,8 +311,10 @@ static void videodev_proc_create_dev (struct video_device *vfd, char *name)
return;
p = create_proc_entry(name, S_IFREG|S_IRUGO|S_IWUSR, video_dev_proc_entry);
if (!p)
if (!p) {
kfree(d);
return;
}
p->data = vfd;
p->read_proc = videodev_proc_read;
......
......@@ -2018,15 +2018,14 @@ static int i2o_systab_send(struct i2o_controller *iop)
{
printk(KERN_ERR "%s: Unable to set SysTab (status=%#x).\n",
iop->name, -ret);
kfree(privbuf);
}
else
{
dprintk(KERN_INFO "%s: SysTab set.\n", iop->name);
kfree(privbuf);
}
i2o_status_get(iop); // Entered READY state
kfree(privbuf);
return ret;
}
......
......@@ -203,6 +203,7 @@ static struct mtd_info *cfi_intelext_setup(struct map_info *map)
if (!mtd->eraseregions) {
printk(KERN_ERR "Failed to allocate memory for MTD erase region info\n");
kfree(cfi->cmdset_priv);
kfree(mtd);
return NULL;
}
......@@ -227,6 +228,7 @@ static struct mtd_info *cfi_intelext_setup(struct map_info *map)
printk(KERN_WARNING "Sum of regions (%lx) != total size of set of interleaved chips (%lx)\n", offset, devsize);
kfree(mtd->eraseregions);
kfree(cfi->cmdset_priv);
kfree(mtd);
return NULL;
}
......
......@@ -174,6 +174,7 @@ static struct mtd_info *cfi_amdstd_setup(struct map_info *map)
if (!mtd->eraseregions) {
printk(KERN_WARNING "Failed to allocate memory for MTD erase region info\n");
kfree(cfi->cmdset_priv);
kfree(mtd);
return NULL;
}
......@@ -197,6 +198,7 @@ static struct mtd_info *cfi_amdstd_setup(struct map_info *map)
printk(KERN_WARNING "Sum of regions (%lx) != total size of set of interleaved chips (%lx)\n", offset, devsize);
kfree(mtd->eraseregions);
kfree(cfi->cmdset_priv);
kfree(mtd);
return NULL;
}
#if 0
......
......@@ -116,8 +116,10 @@ struct mtd_info *sharp_probe(struct map_info *map)
return NULL;
sharp = kmalloc(sizeof(*sharp), GFP_KERNEL);
if(!sharp)
if(!sharp) {
kfree(mtd);
return NULL;
}
memset(mtd, 0, sizeof(*mtd));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment