]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
i3c: fix refcount inconsistency in i3c_master_register
authorFrank Li <Frank.Li@nxp.com>
Thu, 16 Oct 2025 14:38:13 +0000 (10:38 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Dec 2025 13:02:44 +0000 (14:02 +0100)
commitc704ccb558eef6704cccc2b4f8f22e09ae0ebe6f
treef0be8546f2f0cd71de558b7b840a84aca0a8f4b6
parent670b969647302b16fa88a179b1950714da18f2c5
i3c: fix refcount inconsistency in i3c_master_register

[ Upstream commit 9d4f219807d5ac11fb1d596e4ddb09336b040067 ]

In `i3c_master_register`, a possible refcount inconsistency has been
identified, causing possible resource leak.

Function `of_node_get` increases the refcount of `parent->of_node`. If
function `i3c_bus_init` fails, the function returns immediately without
a corresponding decrease, resulting in an inconsistent refcounter.

Move call i3c_bus_init() after device_initialize() to let callback
i3c_masterdev_release() release of_node.

Reported-by: Shuhao Fu <sfual@cse.ust.hk>
Closes: https://lore.kernel.org/linux-i3c/aO2tjp_FsV_WohPG@osx.local/T/#m2c05a982beeb14e7bf039c1d8db856734bf234c7
Fixes: 3a379bbcea0a ("i3c: Add core I3C infrastructure")
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20251016143814.2551256-1-Frank.Li@nxp.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/i3c/master.c