From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Yinghai Lu <yinghai@kernel.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>,
ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Bjorn Helgaas <bhelgaas@google.com>, Jiang Liu <liuj97@gmail.com>,
Toshi Kani <toshi.kani@hp.com>,
Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>,
Myron Stowe <mstowe@redhat.com>,
linux-pci@vger.kernel.org
Subject: Re: [Update][PATCH] ACPI / hotplug: Fix concurrency issues and memory leaks
Date: Thu, 14 Feb 2013 21:17:31 +0100 [thread overview]
Message-ID: <8784737.LSUoM4gnSV@vostro.rjw.lan> (raw)
In-Reply-To: <CAE9FiQW344Q3t6VJYTYTCL_LOvsWFktkzf1doHKdspU-LGU2MA@mail.gmail.com>
On Thursday, February 14, 2013 12:05:43 PM Yinghai Lu wrote:
> On Wed, Feb 13, 2013 at 5:16 AM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> >
> > This changeset is aimed at fixing a few different but related
> > problems in the ACPI hotplug infrastructure.
> >
> > First of all, since notify handlers may be run in parallel with
> > acpi_bus_scan(), acpi_bus_trim() and acpi_bus_hot_remove_device()
> > and some of them are installed for ACPI handles that have no struct
> > acpi_device objects attached (i.e. before those objects are created),
> > those notify handlers have to take acpi_scan_lock to prevent races
> > from taking place (e.g. a struct acpi_device is found to be present
> > for the given ACPI handle, but right after that it is removed by
> > acpi_bus_trim() running in parallel to the given notify handler).
> > Moreover, since some of them call acpi_bus_scan() and
> > acpi_bus_trim(), this leads to the conclusion that acpi_scan_lock
> > should be acquired by the callers of these two funtions rather by
> > these functions themselves.
> >
> > For these reasons, make all notify handlers that can handle device
> > addition and eject events take acpi_scan_lock and remove the
> > acpi_scan_lock locking from acpi_bus_scan() and acpi_bus_trim().
> > Accordingly, update all of their users to make sure that they
> > are always called under acpi_scan_lock.
> >
> > Furthermore, since eject operations are carried out asynchronously
> > with respect to the notify events that trigger them, with the help
> > of acpi_bus_hot_remove_device(), even if notify handlers take the
> > ACPI scan lock, it still is possible that, for example,
> > acpi_bus_trim() will run between acpi_bus_hot_remove_device() and
> > the notify handler that scheduled its execution and that
> > acpi_bus_trim() will remove the device node passed to
> > acpi_bus_hot_remove_device() for ejection. In that case, the struct
> > acpi_device object obtained by acpi_bus_hot_remove_device() will be
> > invalid and not-so-funny things will ensue. To protect agaist that,
> > make the users of acpi_bus_hot_remove_device() run get_device() on
> > ACPI device node objects that are about to be passed to it and make
> > acpi_bus_hot_remove_device() run put_device() on them and check if
> > their ACPI handles are not NULL (make acpi_device_unregister() clear
> > the device nodes' ACPI handles for that check to work).
> >
> > Finally, observe that acpi_os_hotplug_execute() actually can fail,
> > in which case its caller ought to free memory allocated for the
> > context object to prevent leaks from happening. It also needs to
> > run put_device() on the device node that it ran get_device() on
> > previously in that case. Modify the code accordingly.
> >
> > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > Acked-by: Yinghai Lu <yinghai@kernel.org>
> > ---
> >
> > This includes fixes for two issues spotted by Yasuaki Ishimatsu.
> >
>
> this one will make pci/next and pm/linux-next conflicts
>
> Please check if attached fix is right.
Looks correct to me.
Thanks,
Rafael
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
prev parent reply other threads:[~2013-02-14 20:11 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-13 0:19 [PATCH] " Rafael J. Wysocki
2013-02-13 1:55 ` Yinghai Lu
2013-02-13 13:08 ` Rafael J. Wysocki
2013-02-13 3:08 ` Yasuaki Ishimatsu
2013-02-13 3:31 ` Yasuaki Ishimatsu
2013-02-13 13:12 ` Rafael J. Wysocki
2013-02-13 13:16 ` [Update][PATCH] " Rafael J. Wysocki
2013-02-13 17:43 ` Toshi Kani
2013-02-13 20:52 ` Rafael J. Wysocki
2013-02-13 23:09 ` Toshi Kani
2013-02-13 23:42 ` Rafael J. Wysocki
2013-02-14 0:16 ` Toshi Kani
2013-02-14 2:31 ` Moore, Robert
2013-02-14 12:03 ` Rafael J. Wysocki
2013-02-14 20:45 ` Moore, Robert
2013-02-14 20:59 ` Rafael J. Wysocki
2013-02-14 23:45 ` Moore, Robert
2013-02-15 0:23 ` Rafael J. Wysocki
2013-02-15 0:28 ` Toshi Kani
2013-02-15 12:49 ` Rafael J. Wysocki
2013-02-15 15:18 ` Toshi Kani
2013-02-15 16:33 ` Moore, Robert
2013-02-15 17:22 ` Toshi Kani
2013-02-14 20:05 ` Yinghai Lu
2013-02-14 20:17 ` Rafael J. Wysocki [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=8784737.LSUoM4gnSV@vostro.rjw.lan \
--to=rjw@sisk.pl \
--cc=bhelgaas@google.com \
--cc=isimatu.yasuaki@jp.fujitsu.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=liuj97@gmail.com \
--cc=mstowe@redhat.com \
--cc=sfr@canb.auug.org.au \
--cc=toshi.kani@hp.com \
--cc=yinghai@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
all inboxes | Powered by JetHome®