All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
	Stable <stable@vger.kernel.org>
Subject: Re: [PATCH] device property: Fix the secondary firmware node handling in set_primary_fwnode()
Date: Fri, 21 Aug 2020 20:28:07 +0200	[thread overview]
Message-ID: <CAJZ5v0gfX4hqa7RREQX0+=CNCs=pt7bq1AZEMZwRAAzZfGbVsA@mail.gmail.com> (raw)
In-Reply-To: <20200821105342.32368-1-heikki.krogerus@linux.intel.com>

On Fri, Aug 21, 2020 at 12:53 PM Heikki Krogerus
<heikki.krogerus@linux.intel.com> wrote:
>
> When the primary firmware node pointer is removed from a
> device (set to NULL) the secondary firmware node pointer,
> when it exists, is made the primary node for the device.
> However, the secondary firmware node pointer of the original
> primary firmware node is never cleared (set to NULL).
>
> To avoid situation where the secondary firmware node pointer
> is pointing to a non-existing object, clearing it properly
> when the primary node is removed from a device in
> set_primary_fwnode().
>
> Fixes: 97badf873ab6 ("device property: Make it possible to use secondary firmware nodes")
> Cc: stable@vger.kernel.org
> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
>  drivers/base/core.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index ac1046a382bc0..f6f620aa94086 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -4264,9 +4264,9 @@ static inline bool fwnode_is_primary(struct fwnode_handle *fwnode)
>   */
>  void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
>  {
> -       if (fwnode) {
> -               struct fwnode_handle *fn = dev->fwnode;
> +       struct fwnode_handle *fn = dev->fwnode;
>
> +       if (fwnode) {
>                 if (fwnode_is_primary(fn))
>                         fn = fn->secondary;
>
> @@ -4276,8 +4276,12 @@ void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
>                 }
>                 dev->fwnode = fwnode;
>         } else {
> -               dev->fwnode = fwnode_is_primary(dev->fwnode) ?
> -                       dev->fwnode->secondary : NULL;
> +               if (fwnode_is_primary(fn)) {
> +                       dev->fwnode = fn->secondary;
> +                       fn->secondary = NULL;
> +               } else {
> +                       dev->fwnode = NULL;
> +               }
>         }
>  }
>  EXPORT_SYMBOL_GPL(set_primary_fwnode);
> --

Applied as 5.9-rc material, thanks!

      reply	other threads:[~2020-08-21 18:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-21 10:53 [PATCH] device property: Fix the secondary firmware node handling in set_primary_fwnode() Heikki Krogerus
2020-08-21 18:28 ` 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='CAJZ5v0gfX4hqa7RREQX0+=CNCs=pt7bq1AZEMZwRAAzZfGbVsA@mail.gmail.com' \
    --to=rafael@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.