From: Catalin Marinas Subject: Possible memory leak via scsi_sysfs_initialize Date: Mon, 20 Jul 2009 12:58:56 +0100 Message-ID: <1248091136.21585.45.camel@pc1117.cambridge.arm.com> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Return-path: Sender: linux-kernel-owner@vger.kernel.org To: linux-scsi@vger.kernel.org, linux-kernel Cc: Kevin Winchester , Tony Jones , Kay Sievers List-Id: linux-scsi@vger.kernel.org Hi, Kevin (cc'ed) reported several kmemleak warnings like the one below (I cc'ed a few others who seem to have pushed related patches in the past): unreferenced object 0xffff88004e978b68 (size 8): comm "scsi_scan_2", pid 1003, jiffies 4294673552 backtrace: [] create_object+0x188/0x25e [] kmemleak_alloc+0x26/0x4b [] __kmalloc+0x143/0x16d [] kvasprintf+0x45/0x6e [] kobject_set_name_vargs+0x23/0x58 [] dev_set_name+0x69/0x6b [] scsi_sysfs_device_initialize+0xb3/0x10e [] scsi_alloc_sdev+0x189/0x1f7 [] scsi_probe_and_add_lun+0xf4/0x9ff [] __scsi_scan_target+0xa2/0x4d8 [] scsi_scan_channel+0x57/0x7d [] scsi_scan_host_selected+0xa7/0xe9 [] do_scsi_scan_host+0x70/0x75 [] do_scan_async+0x1c/0x10e [] kthread+0x87/0x8f [] child_rip+0xa/0x20 At a first look, these seem to be the objects allocated via dev_set_name(&sdev->sdev_dev) call in scsi_sysfs_device_initialize(). In the past, it was only doing a snprintf() rather than dev_set_name so no allocation occurred. Now, there should be some put_device(&sdev->sdev_dev) in various places like scsi_alloc_sdev() (the out_device_destroy path), maybe instead of put_device(&sdev->sdev_gendev) as the former should be called from scsi_device_cls_release() via put_device(&sdev->sdev_dev). Any thoughts? Thanks. -- Catalin