Skip to content

Commit 4b8209a

Browse files
Yuuoniyvijay-suman
authored andcommitted
cpufreq: nforce2: fix reference count leak in nforce2
commit 9600156bb99852c216a2128cdf9f114eb67c350f upstream. There are two reference count leaks in this driver: 1. In nforce2_fsb_read(): pci_get_subsys() increases the reference count of the PCI device, but pci_dev_put() is never called to release it, thus leaking the reference. 2. In nforce2_detect_chipset(): pci_get_subsys() gets a reference to the nforce2_dev which is stored in a global variable, but the reference is never released when the module is unloaded. Fix both by: - Adding pci_dev_put(nforce2_sub5) in nforce2_fsb_read() after reading the configuration. - Adding pci_dev_put(nforce2_dev) in nforce2_exit() to release the global device reference. Found via static analysis. Fixes: 1da177e ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Signed-off-by: Miaoqian Lin <linmq006@gmail.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit 47e7c7496f5ab70d896e9842ac917a52579c300f) Signed-off-by: Vijayendra Suman <vijayendra.suman@oracle.com>
1 parent 1c4a78e commit 4b8209a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/cpufreq/cpufreq-nforce2.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ static unsigned int nforce2_fsb_read(int bootfsb)
145145
pci_read_config_dword(nforce2_sub5, NFORCE2_BOOTFSB, &fsb);
146146
fsb /= 1000000;
147147

148+
pci_dev_put(nforce2_sub5);
149+
148150
/* Check if PLL register is already set */
149151
pci_read_config_byte(nforce2_dev, NFORCE2_PLLENABLE, (u8 *)&temp);
150152

@@ -432,6 +434,7 @@ static int __init nforce2_init(void)
432434
static void __exit nforce2_exit(void)
433435
{
434436
cpufreq_unregister_driver(&nforce2_driver);
437+
pci_dev_put(nforce2_dev);
435438
}
436439

437440
module_init(nforce2_init);

0 commit comments

Comments
 (0)