]> git.baikalelectronics.ru Git - kernel.git/commit
hwrng: amd - Fix PCI device refcount leak
authorXiongfeng Wang <wangxiongfeng2@huawei.com>
Fri, 2 Dec 2022 13:22:33 +0000 (21:22 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 10:41:21 +0000 (11:41 +0100)
commitbfb02c7db6cfa78b4429cb2b936ec3a4f44c14ec
treec2fed8d7909e0f0972865bd542e05cbb1e4e4d52
parent6e9ceb40133dfc01357939a9bb84d823b67b3d5d
hwrng: amd - Fix PCI device refcount leak

[ Upstream commit 8fcbfdd890bb8235d928bff56635320feab15615 ]

for_each_pci_dev() is implemented by pci_get_device(). The comment of
pci_get_device() says that it will increase the reference count for the
returned pci_dev and also decrease the reference count for the input
pci_dev @from if it is not NULL.

If we break for_each_pci_dev() loop with pdev not NULL, we need to call
pci_dev_put() to decrease the reference count. Add the missing
pci_dev_put() for the normal and error path.

Fixes: baf5b739fb9c ("[PATCH] Add AMD HW RNG driver")
Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/char/hw_random/amd-rng.c