public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH (resend)]: SCSI: fix /proc memory leak in the SCSI core
@ 2009-02-27 15:09 Tony Battersby
  2009-02-27 21:50 ` Alan Stern
  0 siblings, 1 reply; 7+ messages in thread
From: Tony Battersby @ 2009-02-27 15:09 UTC (permalink / raw)
  To: James Bottomley, Alan Stern; +Cc: linux-scsi

I tested Alan's original patch with sym53c8xx back in January:

http://marc.info/?l=linux-scsi&m=123143710010939&w=4

Tested-by: Tony Battersby <tonyb@cybernetics.com>


^ permalink raw reply	[flat|nested] 7+ messages in thread
* [PATCH (resend)]: SCSI: fix /proc memory leak in the SCSI core
@ 2009-02-18 15:52 Alan Stern
  2009-02-22 17:40 ` James Bottomley
  0 siblings, 1 reply; 7+ messages in thread
From: Alan Stern @ 2009-02-18 15:52 UTC (permalink / raw)
  To: James Bottomley; +Cc: Andrew Morton, SCSI development list

The SCSI core calls scsi_proc_hostdir_add() from within
scsi_host_alloc(), but the corresponding scsi_proc_hostdir_rm()
routine is called from within scsi_remove_host().  As a result, if a
host is allocated and then deallocated without ever being registered,
the host's directory in /proc is leaked.

This patch (as1181) fixes this bug in the SCSI core by moving
scsi_proc_hostdir_add() into scsi_host_add().

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>

---

Note: This is a repost of a bug-fix patch that was first submitted on 
December 1.

After looking through the documentation and code for the SCSI legacy 
API, I can't find anything incompatible with this change.  However I 
don't have any hardware with a legacy driver so I can't actually make 
the test.


Index: usb-2.6/drivers/scsi/hosts.c
===================================================================
--- usb-2.6.orig/drivers/scsi/hosts.c
+++ usb-2.6/drivers/scsi/hosts.c
@@ -206,9 +206,10 @@ int scsi_add_host(struct Scsi_Host *shos
 	if (error)
 		goto fail;
 
+	scsi_proc_hostdir_add(shost->hostt);
+
 	if (!shost->shost_gendev.parent)
 		shost->shost_gendev.parent = dev ? dev : &platform_bus;
-
 	error = device_add(&shost->shost_gendev);
 	if (error)
 		goto out;
@@ -259,6 +260,7 @@ int scsi_add_host(struct Scsi_Host *shos
  out_del_gendev:
 	device_del(&shost->shost_gendev);
  out:
+	scsi_proc_hostdir_rm(shost->hostt);
 	scsi_destroy_command_freelist(shost);
  fail:
 	return error;
@@ -407,7 +409,6 @@ struct Scsi_Host *scsi_host_alloc(struct
 		goto fail_kfree;
 	}
 
-	scsi_proc_hostdir_add(shost->hostt);
 	return shost;
 
  fail_kfree:


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-02-27 21:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-27 15:09 [PATCH (resend)]: SCSI: fix /proc memory leak in the SCSI core Tony Battersby
2009-02-27 21:50 ` Alan Stern
  -- strict thread matches above, loose matches on Subject: below --
2009-02-18 15:52 Alan Stern
2009-02-22 17:40 ` James Bottomley
2009-02-22 19:34   ` Alan Stern
2009-02-22 19:46     ` James Bottomley
2009-02-23  0:56       ` Alan Stern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox