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