From: "Jan Beulich" Subject: [PATCH] linux-2.6.18/pcifront: fix PCI reference leak and potential NULL dereference Date: Thu, 11 Nov 2010 13:06:26 +0000 Message-ID: <4CDBF8620200007800021B09@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part577ACD42.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" Cc: Jiri Slaby List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part577ACD42.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline From: Jiri Slaby Subject: pcifront: fix PCI reference leak Stanse found that when pdev is found and has no driver a reference is leaked in pcifront_common_process. So add pci_dev_put there. For the pdev =3D=3D NULL case, pci_dev_put(NULL) is fine. Signed-off-by: Jiri Slaby Cc: Konrad Rzeszutek Wilk Cc: Jesse Barnes From: Jiri Slaby Subject: pcifront: fix potential NULL dereference Milton spotted that we dereference NULL in one fail path in pcifront_common_process. Fix that by using different device to print out an error. Signed-off-by: Jiri Slaby Cc: Milton Miller Signed-off-by: Jan Beulich --- a/drivers/xen/pcifront/pci_op.c +++ b/drivers/xen/pcifront/pci_op.c @@ -592,9 +592,9 @@ static pci_ers_result_t pcifront_common_ result =3D PCI_ERS_RESULT_NONE; =20 pcidev =3D pci_get_bus_and_slot(bus, devfn); - if (!pcidev || !pcidev->driver){ - dev_err(&pcidev->dev,=20 - "device or driver is NULL\n"); + if (!pcidev || !pcidev->driver) { + pci_dev_put(pcidev); + dev_err(&pdev->xdev->dev, "AER device or driver is = NULL\n"); return result; } pdrv =3D pcidev->driver; --=__Part577ACD42.0__= Content-Type: text/plain; name="xen-pcifront-error-handling.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="xen-pcifront-error-handling.patch" From: Jiri Slaby =0ASubject: pcifront: fix PCI reference = leak=0A=0AStanse found that when pdev is found and has no driver a = reference is=0Aleaked in pcifront_common_process. So add pci_dev_put = there. For the=0Apdev =3D=3D NULL case, pci_dev_put(NULL) is fine.=0A=0ASig= ned-off-by: Jiri Slaby =0ACc: Konrad Rzeszutek Wilk = =0ACc: Jesse Barnes =0A= =0AFrom: Jiri Slaby =0ASubject: pcifront: fix potential = NULL dereference=0A=0AMilton spotted that we dereference NULL in one fail = path in=0Apcifront_common_process. Fix that by using different device to = print=0Aout an error.=0A=0ASigned-off-by: Jiri Slaby =0ACc:= Milton Miller =0A=0ASigned-off-by: Jan Beulich =0A=0A--- a/drivers/xen/pcifront/pci_op.c=0A+++ b/drivers/xen/pc= ifront/pci_op.c=0A@@ -592,9 +592,9 @@ static pci_ers_result_t pcifront_comm= on_=0A result =3D PCI_ERS_RESULT_NONE;=0A =0A pcidev =3D pci_get_bus_and_= slot(bus, devfn);=0A- if (!pcidev || !pcidev->driver){=0A- = dev_err(&pcidev->dev, =0A- "device or driver is = NULL\n");=0A+ if (!pcidev || !pcidev->driver) {=0A+ pci_dev_put= (pcidev);=0A+ dev_err(&pdev->xdev->dev, "AER device or driver is = NULL\n");=0A return result;=0A }=0A pdrv =3D pcidev->dr= iver;=0A --=__Part577ACD42.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=__Part577ACD42.0__=--