Memory leak in scsi_debug found by checker
PATCH 1/1 Memory leak in scsi_debug found by checker
Hi James,
Patch against 2.6-test5.
If in the middle of loop a kmalloc failed, that means that the
previous calls succeeded..so they must be also be freed (and removed from the dev_info_list).
Please review and consider applying.
Cheers,
Felipe
Forgot the patch :)
Quoted 4 lines · Felipe W Damasio
Hi James,
Patch against 2.6-test5.
Quoted 9 lines
If in the middle of loop a kmalloc failed, that means that the
previous calls succeeded..so they must be also be freed (and removed from thedev_info_list).Please review and consider applying.
Cheers,
Felipe
drivers/scsi/scsi_debug.c renamed from drivers/scsi/scsi_debug.c.orig +3 -4
@@ -1614,7 +1614,7 @@printk (KERN_ERR "%s: out of memory at line %d\n" , __FUNCTION__, __LINE__); error = -ENOMEM ; - goto clean1; + goto clean; }memset (sdbg_devinfo,0 ,sizeof (*sdbg_devinfo)); sdbg_devinfo->sdbg_host = sdbg_host;
@@ -1634,12 +1634,12 @@ error =device_register (&sdbg_host->dev);if (error) - goto clean2; + goto clean; ++scsi_debug_add_host;return error; -clean2: +clean:list_for_each_safe (lh, lh_sf, &sdbg_host->dev_info_list) { sdbg_devinfo = list_entry(lh, struct sdebug_dev_info, dev_list);
@@ -1647,7 +1647,6 @@kfree (sdbg_devinfo); } -clean1:kfree (sdbg_host);return error; }