From: Boaz Harrosh <bharrosh@panasas.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>,
SCSI development list <linux-scsi@vger.kernel.org>
Subject: Re: [PATCH] SCSI: fix /proc memory leak in the SCSI core
Date: Mon, 01 Dec 2008 17:43:06 +0200 [thread overview]
Message-ID: <4934060A.9050809@panasas.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0812011024430.2212-100000@iolanthe.rowland.org>
Alan Stern wrote:
> 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>
>
Nice this also fixes the premature visibility of the directory
and the theoretical races, that can cause.
> ---
>
> Can somebody check to make sure this is compatible with legacy drivers
> using the non-hotplug API?
>
>
>
> 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:
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2008-12-01 15:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-01 15:26 [PATCH] SCSI: fix /proc memory leak in the SCSI core Alan Stern
2008-12-01 15:43 ` Boaz Harrosh [this message]
2008-12-01 15:51 ` Alan Stern
2009-01-13 16:59 ` James Bottomley
2009-01-13 17:16 ` Alan Stern
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4934060A.9050809@panasas.com \
--to=bharrosh@panasas.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=linux-scsi@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox