MIPS: SGI-IP27: Fix platform-device leak in bridge_platform_create()
authorLin Yujun <linyujun809@huawei.com>
Wed, 14 Sep 2022 03:29:17 +0000 (11:29 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Oct 2022 11:25:18 +0000 (13:25 +0200)
commitda2aecef866b476438d02c662507a0e4e818da9d
tree32aea79a2e3647a44c72ddb46273c9f7e3d97bd4
parent0c667858c0266f46a33327259169657bc54b7334
MIPS: SGI-IP27: Fix platform-device leak in bridge_platform_create()

[ Upstream commit 11bec9cba4de06b3c0e9e4041453c2caaa1cbec1 ]

In error case in bridge_platform_create after calling
platform_device_add()/platform_device_add_data()/
platform_device_add_resources(), release the failed
'pdev' or it will be leak, call platform_device_put()
to fix this problem.

Besides, 'pdev' is divided into 'pdev_wd' and 'pdev_bd',
use platform_device_unregister() to release sgi_w1
resources when xtalk-bridge registration fails.

Fixes: 5dc76a96e95a ("MIPS: PCI: use information from 1-wire PROM for IOC3 detection")
Signed-off-by: Lin Yujun <linyujun809@huawei.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/mips/sgi-ip27/ip27-xtalk.c