Re: refcount leak in pci_get_device()?

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Matthew Wilcox <matthew@...>
Cc: Alex Chiang <achiang@...>, <linux-pci@...>, <linux-kernel@...>
Date: Thursday, August 21, 2008 - 4:47 pm

On Thu, Aug 21, 2008 at 02:25:04PM -0600, Matthew Wilcox wrote:

Ah, no the driver core isn't supposed to do this, it's something the pci
functions do out of "niceness" as that's how we can use them in an
iterator properly.

Does the following (untested) patch fix the issue for you all?

thanks,

greg k-h

--------------
Subject: PCI: fix reference leak in pci_get_dev_by_id()

From: Greg Kroah-Hartman <gregkh@suse.de>

Alex Chiang and Matthew Wilcox pointed out that pci_get_dev_by_id() does
not properly decrement the reference on the from pointer if it is
present, like the documentation for the function states it will.

Cc: Matthew Wilcox <matthew@wil.cx>
Cc: Alex Chiang <achiang@hp.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index 217814f..3b3b5f1 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -280,6 +280,8 @@ static struct pci_dev *pci_get_dev_by_id(const struct pci_device_id *id,
 			      match_pci_dev_by_id);
 	if (dev)
 		pdev = to_pci_dev(dev);
+	if (from)
+		pci_dev_put(from);
 	return pdev;
 }
 
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
refcount leak in pci_get_device()?, Alex Chiang, (Thu Aug 21, 4:19 pm)
Re: refcount leak in pci_get_device()?, Greg KH, (Thu Aug 21, 4:40 pm)
Re: refcount leak in pci_get_device()?, Matthew Wilcox, (Thu Aug 21, 4:25 pm)
Re: refcount leak in pci_get_device()?, Greg KH, (Thu Aug 21, 4:47 pm)
Re: refcount leak in pci_get_device()?, Jesse Barnes, (Thu Aug 21, 6:23 pm)
Re: refcount leak in pci_get_device()?, Henrique de Moraes Holschuh..., (Thu Aug 21, 9:04 pm)
Re: refcount leak in pci_get_device()?, Henrique de Moraes Holschuh..., (Thu Aug 21, 9:09 pm)
Re: refcount leak in pci_get_device()?, Alex Chiang, (Thu Aug 21, 6:14 pm)
RE: refcount leak in pci_get_device()?, Zhao, Yu, (Sat Aug 30, 12:23 am)
Re: refcount leak in pci_get_device()?, Greg KH, (Sat Aug 30, 1:37 am)
RE: refcount leak in pci_get_device()?, Zhao, Yu, (Sat Aug 30, 2:20 am)
[PATCH] PCI Hotplug: fakephp: fix deadlock... again, Alex Chiang, (Mon Sep 1, 2:40 pm)
Re: [PATCH] PCI Hotplug: fakephp: fix deadlock... again, Matthew Wilcox, (Mon Sep 1, 8:10 pm)
Re: [PATCH] PCI Hotplug: fakephp: fix deadlock... again, Jesse Barnes, (Tue Sep 9, 12:12 am)
Re: [PATCH] PCI Hotplug: fakephp: fix deadlock... again, Matthew Wilcox, (Tue Sep 9, 12:27 am)
Re: [PATCH] PCI Hotplug: fakephp: fix deadlock... again, Andrew Patterson, (Tue Sep 9, 1:32 am)