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 amd-hwrng and geode-hwrng. ChangeLog: v1 -> v2: 1. fix error in amd_rng_mod_exit() 2. also add refcount leak fix for geode-hwrng Xiongfeng Wang (2): hwrng: amd - Fix PCI device refcount leak hwrng: geode - Fix PCI device refcount leak drivers/char/hw_random/amd-rng.c | 18 ++++++++++----- drivers/char/hw_random/geode-rng.c | 36 +++++++++++++++++++++++------- 2 files changed, 41 insertions(+), 13 deletions(-) -- 2.20.1