From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EED9815E8B; Mon, 30 Dec 2024 15:54:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735574100; cv=none; b=JdRQG6lav8F5vij95JfjqzzaX4rAeg3e3J1bLu+IAH/kKKaEFadxKQFIJud3BJHMKxMavFWtDFSE7wPr8LrpQLCtDLfdyIB/yp36n9ja+vECWtYwyuGHjU+v3tD7QOn1xPYpAwnSkgcCXhs6ag79/wUg32jhc1+H2w9a5010Q2s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735574100; c=relaxed/simple; bh=rB2Nf9vpvsIYpfSvDwJoqrKNc13c9w0zy0lnoPoGTcM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YGtYddCZf0ho68dV5raU21tY8nM8fuvda2077RD1Ob7aZVgJIIGARxZo16hpdJbrvk8Q5HP1sN65piUHWRgZEmfZLzKIeCnEFY76se7dc7+SUBkpRTBpuwZiDNx7moKQxHwD0elSQg1BtTTt6+EfBhRG16dB9Wht6fPpnXpsOXY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=wHd72Jl5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="wHd72Jl5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A2ADC4CED0; Mon, 30 Dec 2024 15:54:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1735574099; bh=rB2Nf9vpvsIYpfSvDwJoqrKNc13c9w0zy0lnoPoGTcM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wHd72Jl5ttlMwL9cU3EG47VpThPhJzAPs8wF/geRX0wm7tpiJ8+FSzAWU/UB0S7k8 ZkDN83kssuPPgDX8ctiFgmm7fYk6vhMUMSGwM+313QqGqo3ISZVGkMoLYcOrRuGzMp 1F4AxeLMM4WCtvGLs2kuYBg1nBkaRvDsZ5tv62Xg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Johan Hovold , Zijun Hu , Vinod Koul Subject: [PATCH 6.12 019/114] phy: core: Fix an OF node refcount leakage in _of_phy_get() Date: Mon, 30 Dec 2024 16:42:16 +0100 Message-ID: <20241230154218.803299003@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241230154218.044787220@linuxfoundation.org> References: <20241230154218.044787220@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zijun Hu commit 5ebdc6be16c2000e37fcb8b4072d442d268ad492 upstream. _of_phy_get() will directly return when suffers of_device_is_compatible() error, but it forgets to decrease refcount of OF node @args.np before error return, the refcount was increased by previous of_parse_phandle_with_args() so causes the OF node's refcount leakage. Fix by decreasing the refcount via of_node_put() before the error return. Fixes: b7563e2796f8 ("phy: work around 'phys' references to usb-nop-xceiv devices") Cc: stable@vger.kernel.org Reviewed-by: Johan Hovold Signed-off-by: Zijun Hu Link: https://lore.kernel.org/r/20241213-phy_core_fix-v6-4-40ae28f5015a@quicinc.com Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman --- drivers/phy/phy-core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -629,8 +629,10 @@ static struct phy *_of_phy_get(struct de 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")) - return ERR_PTR(-ENODEV); + if (of_device_is_compatible(args.np, "usb-nop-xceiv")) { + phy = ERR_PTR(-ENODEV); + goto out_put_node; + } mutex_lock(&phy_provider_mutex); phy_provider = of_phy_provider_lookup(args.np); @@ -652,6 +654,7 @@ out_put_module: out_unlock: mutex_unlock(&phy_provider_mutex); +out_put_node: of_node_put(args.np); return phy;