linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ferry Toth <fntoth@gmail.com>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org,
	Saravana Kannan <saravanak@google.com>,
	linux-acpi@vger.kernel.org,
	"Rafael J. Wysocki" <rafael@kernel.org>
Subject: Re: [PATCH v1 2/2] device property: Don't clear secondary pointer for shared primary firmware node
Date: Fri, 23 Oct 2020 16:16:35 +0200	[thread overview]
Message-ID: <06eb930d-841f-29d9-e1e3-1f54d7bf10ca@gmail.com> (raw)
In-Reply-To: <20201023123544.GB614478@kuha.fi.intel.com>

Hi

Op 23-10-2020 om 14:35 schreef Heikki Krogerus:
> On Thu, Oct 22, 2020 at 09:41:00PM +0300, Andy Shevchenko wrote:
>> It appears that firmware nodes can be shared between devices. In such 
>> case
>> when a (child) device is about to be deleted, its firmware node may 
>> be shared
>> and ACPI_COMPANION_SET(..., NULL) call for it breaks the secondary link
>> of the shared primary firmware node.
>>
>> In order to prevent that, check, if the device has a parent and parent's
>> firmware node is shared with its child, and avoid crashing the link.
>>
>> Fixes: c15e1bdda436 ("device property: Fix the secondary firmware 
>> node handling in set_primary_fwnode()")
>> Reported-by: Ferry Toth <fntoth@gmail.com>
>> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> FWIW:
>
> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

Tested-by: Ferry Toth <fntoth@gmail.com>

>> ---
>> drivers/base/core.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/base/core.c b/drivers/base/core.c
>> index 41feab679fa1..78114ddac755 100644
>> --- a/drivers/base/core.c
>> +++ b/drivers/base/core.c
>> @@ -4264,6 +4264,7 @@ static inline bool fwnode_is_primary(struct 
>> fwnode_handle *fwnode)
>> */
>> void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
>> {
>> + struct device *parent = dev->parent;
>> struct fwnode_handle *fn = dev->fwnode;
>> if (fwnode) {
>> @@ -4278,7 +4279,8 @@ void set_primary_fwnode(struct device *dev, 
>> struct fwnode_handle *fwnode)
>> } else {
>> if (fwnode_is_primary(fn)) {
>> dev->fwnode = fn->secondary;
>> - fn->secondary = ERR_PTR(-ENODEV);
>> + if (!(parent && fn == parent->fwnode))
>> + fn->secondary = ERR_PTR(-ENODEV);
>> } else {
>> dev->fwnode = NULL;
>> }
>> -- 2.28.0

  parent reply	other threads:[~2020-10-23 14:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-22 18:40 [PATCH v1 1/2] device property: Keep secondary firmware node secondary by type Andy Shevchenko
2020-10-22 18:41 ` [PATCH v1 2/2] device property: Don't clear secondary pointer for shared primary firmware node Andy Shevchenko
2020-10-23 12:35   ` Heikki Krogerus
2020-10-23 14:03     ` Ferry Toth
2020-10-23 14:16     ` Ferry Toth [this message]
2020-10-23 12:34 ` [PATCH v1 1/2] device property: Keep secondary firmware node secondary by type Heikki Krogerus
2020-10-23 14:16   ` Ferry Toth
     [not found]   ` <ef59c911-8d8b-783a-c756-05123f428302@gmail.com>
2020-10-23 14:19     ` Andy Shevchenko
2020-10-27 18:21 ` Rafael J. Wysocki

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=06eb930d-841f-29d9-e1e3-1f54d7bf10ca@gmail.com \
    --to=fntoth@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=saravanak@google.com \
    /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).