Subject: Re: [PATCH] CXL: Fix device_node reference counting

From: Michael Ellerman <[email-masked]>
Date: Wed, 28 Jan 2015 16:04:40 +1100

On Wed, 2015-01-28 at 15:02 +1100, Ian Munsie wrote:
> Excerpts from Ian Munsie's message of 2015-01-07 16:41:18 +1100:
> > From: Ryan Grimm <[email-masked]>
> > 
> > When unbinding and rebinding the driver on a system with a card in PHB0, this
> > error condition is reached after a few attempts:
> 
> Hey mpe,
> 
> I just wanted to check the status of this one? I can't see it in your
> tree and wanted to make sure you didn't simply miss it.

It looked fishy, but I never got around to replying.

The second sentence in the explanation should never be true:

  But, if while loop is not entered, of_node_put get called
  on np without an of_node_get.

You shouldn't have np unless you did an of_node_get() to get it, otherwise it's
pointing at something you don't have a reference for and it might go away at
any time.

So the patch may fix the bug but I don't think it's correct.

I think pnv_pci_to_phb_node() should be doing a get for you, before returning
the pointer.

See as a comparison pcibios_get_phb_of_node().

cheers