[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9ddb14c5-b425-474a-9a53-d34a414c3d17@icloud.com>
Date: Tue, 29 Oct 2024 23:41:41 +0800
From: Zijun Hu <zijun_hu@...oud.com>
To: Johan Hovold <johan@...nel.org>
Cc: Vinod Koul <vkoul@...nel.org>, Kishon Vijay Abraham I
<kishon@...nel.org>, Felipe Balbi <balbi@...com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Rob Herring <robh@...nel.org>, Arnd Bergmann <arnd@...db.de>,
Lee Jones <lee@...nel.org>, Lorenzo Pieralisi <lpieralisi@...nel.org>,
Krzysztof WilczyĆski <kw@...ux.com>,
Bjorn Helgaas <bhelgaas@...gle.com>, "David S. Miller"
<davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Christophe JAILLET <christophe.jaillet@...adoo.fr>, stable@...r.kernel.org,
linux-phy@...ts.infradead.org, linux-kernel@...r.kernel.org,
Zijun Hu <quic_zijuhu@...cinc.com>
Subject: Re: [PATCH v2 4/6] phy: core: Fix an OF node refcount leakage in
_of_phy_get()
On 2024/10/29 21:47, Johan Hovold wrote:
> On Thu, Oct 24, 2024 at 10:39:29PM +0800, Zijun Hu wrote:
>> From: Zijun Hu <quic_zijuhu@...cinc.com>
>>
>> It will leak refcount of OF node @args.np for _of_phy_get() not to
>> decrease refcount increased by previous of_parse_phandle_with_args()
>> when returns due to of_device_is_compatible() error.
>>
>> Fix by adding of_node_put() before the error return.
>>
>> Fixes: b7563e2796f8 ("phy: work around 'phys' references to usb-nop-xceiv devices")
>> Cc: stable@...r.kernel.org
>> Signed-off-by: Zijun Hu <quic_zijuhu@...cinc.com>
>> ---
>> drivers/phy/phy-core.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
>> index 52ca590a58b9..967878b78797 100644
>> --- a/drivers/phy/phy-core.c
>> +++ b/drivers/phy/phy-core.c
>> @@ -629,8 +629,11 @@ static struct phy *_of_phy_get(struct device_node *np, int index)
>> return ERR_PTR(-ENODEV);
>>
>> /* This phy type handled by the usb-phy subsystem for now */
>> - if (of_device_is_compatible(args.np, "usb-nop-xceiv"))
>> + if (of_device_is_compatible(args.np, "usb-nop-xceiv")) {
>> + /* Put refcount above of_parse_phandle_with_args() got */
>
> No need for a comment as this is already handled in the later paths.
>
will remove it within v3
>> + of_node_put(args.np);
>
> For that reason you should probably initialise ret and add a new label
> out_put_node that you jump to here instead.
>
will try to do it within v3.
>> return ERR_PTR(-ENODEV);
>> + }
>>
>> mutex_lock(&phy_provider_mutex);
>> phy_provider = of_phy_provider_lookup(args.np);
>
> Johan
Powered by blists - more mailing lists