i3c: Fix potential refcount leak in i3c_master_register_new_i3c_devs
authorDinghao Liu <dinghao.liu@zju.edu.cn>
Thu, 21 Sep 2023 08:24:10 +0000 (16:24 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 20 Nov 2023 10:59:29 +0000 (11:59 +0100)
commite49a51a96b531f1b4bcd8d358e645b6c74ef67e6
tree610380223a46140f6be68c8a30bfddcbb54a9ba2
parent58d47044f6394c566052f0550c207aca970c0fc6
i3c: Fix potential refcount leak in i3c_master_register_new_i3c_devs

[ Upstream commit cab63f64887616e3c4e31cfd8103320be6ebc8d3 ]

put_device() needs to be called on failure of device_register()
to give up the reference initialized in it to avoid refcount leak.

Fixes: 3a379bbcea0a ("i3c: Add core I3C infrastructure")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Link: https://lore.kernel.org/r/20230921082410.25548-1-dinghao.liu@zju.edu.cn
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/i3c/master.c