Skip to content

Commit 7dec145

Browse files
Yang Yinglianggroeck
authored andcommitted
hwmon: (coretemp) fix pci device refcount leak in nv1a_ram_new()
As comment of pci_get_domain_bus_and_slot() says, it returns a pci device with refcount increment, when finish using it, the caller must decrement the reference count by calling pci_dev_put(). So call it after using to avoid refcount leak. Fixes: 14513ee ("hwmon: (coretemp) Use PCI host bridge ID to identify CPU if necessary") Signed-off-by: Yang Yingliang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
1 parent a89ff5f commit 7dec145

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/hwmon/coretemp.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,13 @@ static int adjust_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev)
242242
*/
243243
if (host_bridge && host_bridge->vendor == PCI_VENDOR_ID_INTEL) {
244244
for (i = 0; i < ARRAY_SIZE(tjmax_pci_table); i++) {
245-
if (host_bridge->device == tjmax_pci_table[i].device)
245+
if (host_bridge->device == tjmax_pci_table[i].device) {
246+
pci_dev_put(host_bridge);
246247
return tjmax_pci_table[i].tjmax;
248+
}
247249
}
248250
}
251+
pci_dev_put(host_bridge);
249252

250253
for (i = 0; i < ARRAY_SIZE(tjmax_table); i++) {
251254
if (strstr(c->x86_model_id, tjmax_table[i].id))

0 commit comments

Comments
 (0)