hostap_{pci,plx}.c: fix memory leaks
Subsystems (3)
PATCH 1/1 hostap_{pci,plx}.c: fix memory leaks
This patch fixes two memotry leaks spotted by the Coverity checker.
---
drivers/net/wireless/hostap/hostap_pci.c | 6 +++--- drivers/net/wireless/hostap/hostap_plx.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/wireless/hostap/hostap_pci.c renamed from drivers/net/wireless/hostap/hostap_pci.c.old +3 -3
@@ -301,14 +301,14 @@ static int prism2_pci_probe(struct pci_dstruct hostap_interface *iface;struct hostap_pci_priv *hw_priv; +if (pci_enable_device (pdev)) +return -EIO ; + hw_priv =kmalloc (sizeof (*hw_priv),GFP_KERNEL );if (hw_priv ==NULL )return -ENOMEM ;memset (hw_priv,0 ,sizeof (*hw_priv)); -if (pci_enable_device (pdev)) -return -EIO ; - phymem =pci_resource_start (pdev,0 );if (!request_mem_region (phymem,pci_resource_len (pdev,0 ),"Prism2" )) {
drivers/net/wireless/hostap/hostap_plx.c renamed from drivers/net/wireless/hostap/hostap_plx.c.old +3 -3
@@ -446,14 +446,14 @@ static int prism2_plx_probe(struct pci_dint tmd7160;struct hostap_plx_priv *hw_priv; +if (pci_enable_device (pdev)) +return -EIO ; + hw_priv =kmalloc (sizeof (*hw_priv),GFP_KERNEL );if (hw_priv ==NULL )return -ENOMEM ;memset (hw_priv,0 ,sizeof (*hw_priv)); -if (pci_enable_device (pdev)) -return -EIO ; -/* National Datacomm NCP130 based on TMD7160, not PLX9052. */ tmd7160 = (pdev->vendor ==0x15e8 ) && (pdev->device ==0x0131 );
drivers/net/wireless/hostap/hostap_pci.c static int prism2_pci_probe(struct pci_d · line 311
Quoted 12 lines · Adrian Bunk
drivers/net/wireless/hostap/hostap_pci.c renamed from drivers/net/wireless/hostap/hostap_pci.c.old +3
-3+if (pci_enable_device (pdev)) +return -EIO ; + hw_priv =kmalloc (sizeof (*hw_priv),GFP_KERNEL );if (hw_priv ==NULL )return -ENOMEM ;memset (hw_priv,0 ,sizeof (*hw_priv)); -if (pci_enable_device (pdev)) -return -EIO ; -
You've just turned it into a leak of a different kind.
Why not jump to the error exit instead?
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtQuoted 14 lines · you
This patch fixes two memotry leaks spotted by the Coverity checker.
Signed-off-by Adrian Bunk <[email protected]>---
drivers/net/wireless/hostap/hostap_pci.c | 6 +++--- drivers/net/wireless/hostap/hostap_plx.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/wireless/hostap/hostap_pci.c static int prism2_pci_probe(struct pci_d · line 308
Quoted 8 lines
drivers/net/wireless/hostap/hostap_pci.c renamed from drivers/net/wireless/hostap/hostap_pci.c.old +3
-0@@ -301,14 +301,14 @@ static int prism2_pci_probe(struct pci_dstruct hostap_interface *iface;struct hostap_pci_priv *hw_priv; +if (pci_enable_device (pdev)) +return -EIO ; + hw_priv =kmalloc (sizeof (*hw_priv),GFP_KERNEL );if (hw_priv ==NULL )
+ pci_disable_device(pdev);
Quoted 12 lines
drivers/net/wireless/hostap/hostap_pci.c renamed from drivers/net/wireless/hostap/hostap_pci.c.old +0
-3return -ENOMEM ;memset (hw_priv,0 ,sizeof (*hw_priv)); -if (pci_enable_device (pdev)) -return -EIO ; - phymem =pci_resource_start (pdev,0 );if (!request_mem_region (phymem,pci_resource_len (pdev,0 ),"Prism2" )) {
drivers/net/wireless/hostap/hostap_plx.c static int prism2_plx_probe(struct pci_d · line 453
Quoted 8 lines
drivers/net/wireless/hostap/hostap_plx.c renamed from drivers/net/wireless/hostap/hostap_plx.c.old +3
-0@@ -446,14 +446,14 @@ static int prism2_plx_probe(struct pci_dint tmd7160;struct hostap_plx_priv *hw_priv; +if (pci_enable_device (pdev)) +return -EIO ; + hw_priv =kmalloc (sizeof (*hw_priv),GFP_KERNEL );if (hw_priv ==NULL )
Seems like pci_disable_device should be done here, too.
Quoted 8 lines
drivers/net/wireless/hostap/hostap_plx.c renamed from drivers/net/wireless/hostap/hostap_plx.c.old +0
-3return -ENOMEM ;memset (hw_priv,0 ,sizeof (*hw_priv)); -if (pci_enable_device (pdev)) -return -EIO ; -/* National Datacomm NCP130 based on TMD7160, not PLX9052. */ tmd7160 = (pdev->vendor ==0x15e8 ) && (pdev->device ==0x0131 );
Signature · 1 line
Greetings Michael.
Quoted 1 line · Adrian Bunk
This patch fixes two memotry leaks spotted by the Coverity checker.
Thanks. I'll make a bit different patch to resolve this and related PCI "leaks" in one change. I'm going through the Coverity reports for Host AP driver, so I'll include other fixes in a patch set, too.
Signature · 1 line
Jouni Malinen PGP id EFC895FA
Quoted 6 lines · Jouni Malinen
Quoted 1 line · Adrian Bunk
This patch fixes two memotry leaks spotted by the Coverity checker.
Thanks. I'll make a bit different patch to resolve this and related PCI "leaks" in one change. I'm going through the Coverity reports for Host AP driver, so I'll include other fixes in a patch set, too.
Thanks (I assume you've seem Herbert's comment why my patch was wrong).
Quoted 1 line
Jouni Malinen PGP id EFC895FA
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed