Re: two leaks in scsi_alloc_sdev failure paths

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 09, 2006 at 09:07:34AM -0600, Brian King wrote:
 > Dave Jones wrote:
 > >If the scsi_alloc_queue or the slave_alloc calls in scsi_alloc_device fail,
 > >we forget to release the locally allocated sdev on the failure path.
 > 
 > Actually, I think the slave_alloc failure path works today, and this patch
 > breaks it. Today, in the slave_alloc failure path, the release function 
 > called
 > as a result of the put_device in out_device_destroy should end up freeing 
 > the sdev.

Correct, thanks.

 > Rather than this change, I think just adding a kfree(sdev) before the goto 
 > out would accomplish what you want.

looks a lot simpler.

Thanks.

		Dave



If the scsi_alloc_queue or the slave_alloc calls in scsi_alloc_device fail,
we forget to release the locally allocated sdev on the failure path.

Coverity #609
Signed-off-by: Dave Jones <davej@xxxxxxxxxx>

--- linux-2.6/drivers/scsi/scsi_scan.c~	2006-03-09 10:19:51.000000000 -0500
+++ linux-2.6/drivers/scsi/scsi_scan.c	2006-03-09 10:20:20.000000000 -0500
@@ -252,6 +252,7 @@ static struct scsi_device *scsi_alloc_sd
 		/* release fn is set up in scsi_sysfs_device_initialise, so
 		 * have to free and put manually here */
 		put_device(&starget->dev);
+		kfree(sdev);
 		goto out;
 	}
 

-- 
http://www.codemonkey.org.uk
-
: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux