From: Jeff Garzik <jgarzik@pobox.com>
To: "Adam J. Richter" <adam@yggdrasil.com>
Cc: linux-ide@vger.kernel.org
Subject: Re: [Patch? 2.6.10-rc3-bk17] ata_pci_remove_one used freed memory
Date: Sat, 05 Feb 2005 23:24:49 -0500 [thread overview]
Message-ID: <42059C11.4020501@pobox.com> (raw)
In-Reply-To: <200412250820.iBP8K3421640@freya.yggdrasil.com>
Adam J. Richter wrote:
> Attempting to unload a serial ATA driver module gave me a kernel
> memory fault. I think this problem occurs in all configurations, but
> I should mention that my configuration may be slightly unusual in that
> I configured my BIOS not to do IDE emulation with SATA disks, and I don't
> actually have any disks plugged in.
>
> The problem was that ata_pci_remove_one would call
> scsi_host_put(ap->host), which would free the memory used to hold
> host_set->ports, but host_set->ports was used later in ata_pci_remove_one.
>
> So, the following patch reorders some of the steps in
> ata_pci_remove_one and seems to eliminate the problem, at least to
> the extent that I can unload and reload the module, although I do not
> have a SATA disk handy for testing (I'm expecting one to arrive later
> today).
>
> The patch actually makes the code four lines shorter, although
> two of those lines come from putting an assignement and variable
> declaration in the same line. Since the patch is a little hard to
> read, here is a description of the edit steps.
>
> 1. Moved pci_release_regions() to toward the end of the routine
> to facilitate merging the loops before and after it. Also, I think that
> calls that are good candidates for consolidating into the bus-level code
> in the future (instead of individual drivers) are best put at the beginning
> or end of the driver routines so that it is clearer if there would be
> problems doing such consolidation.
>
> 2. Moved the cacluation of ioaddr into the only if-branch that
> uses it.
>
> 3. Moved the call to scsi_host_put to after the code that
> checks ATA_FLAG_NO_LEGACY.
Applied to libata-dev, but #3 looks wrong: you always release the
kernel subsystem before releasing the hardware resources.
I won't push it upstream until I ponder this some more (and/or an
increment patch for this issue appears).
Jeff
prev parent reply other threads:[~2005-02-06 4:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-25 8:20 [Patch? 2.6.10-rc3-bk17] ata_pci_remove_one used freed memory Adam J. Richter
2005-02-06 4:24 ` Jeff Garzik [this message]
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=42059C11.4020501@pobox.com \
--to=jgarzik@pobox.com \
--cc=adam@yggdrasil.com \
--cc=linux-ide@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).