applicom: Fix PCI device refcount leak in applicom_init()
authorXiongfeng Wang <wangxiongfeng2@huawei.com>
Tue, 22 Nov 2022 11:40:35 +0000 (19:40 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Mar 2023 08:39:38 +0000 (09:39 +0100)
commit7f9416f14e86c9d27e5d9c37963f71fdc230a15a
tree796bcab7186feca0f232adaf2d54a2e71b18547e
parent4a77ce51f9a801fd62e845288688f98ca3d3bd32
applicom: Fix PCI device refcount leak in applicom_init()

[ Upstream commit ce4273d89c52167d6fe20572136c58117eae0657 ]

As comment of pci_get_class() says, it returns a pci_device with its
refcount increased and decreased the refcount for the input parameter
@from if it is not NULL.

If we break the loop in applicom_init() with 'dev' not NULL, we need to
call pci_dev_put() to decrease the refcount. Add the missing
pci_dev_put() to avoid refcount leak.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
Link: https://lore.kernel.org/r/20221122114035.24194-1-wangxiongfeng2@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/char/applicom.c