public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] Staging: vt6655-6: potential NULL dereference in hostap_disable_hostapd()
@ 2013-11-07  7:55 Dan Carpenter
  2013-11-07  8:45 ` Waskiewicz Jr, Peter P
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dan Carpenter @ 2013-11-07  7:55 UTC (permalink / raw)
  To: kernel-janitors

We fixed this to use free_netdev() instead of kfree() but unfortunately
free_netdev() doesn't accept NULL pointers.  Smatch complains about
this, it's not something I discovered through testing.

Fixes: 3030d40b5036 ('staging: vt6655: use free_netdev instead of kfree')
Fixes: 0a438d5b381e ('staging: vt6656: use free_netdev instead of kfree')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
index aab0012..ab8b2ba 100644
--- a/drivers/staging/vt6655/hostap.c
+++ b/drivers/staging/vt6655/hostap.c
@@ -143,7 +143,8 @@ static int hostap_disable_hostapd(PSDevice pDevice, int rtnl_locked)
 		DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Netdevice %s unregistered\n",
 			pDevice->dev->name, pDevice->apdev->name);
 	}
-	free_netdev(pDevice->apdev);
+	if (pDevice->apdev)
+		free_netdev(pDevice->apdev);
 	pDevice->apdev = NULL;
 	pDevice->bEnable8021x = false;
 	pDevice->bEnableHostWEP = false;
diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
index ae1676d..67ba48b 100644
--- a/drivers/staging/vt6656/hostap.c
+++ b/drivers/staging/vt6656/hostap.c
@@ -133,7 +133,8 @@ static int hostap_disable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
             DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Netdevice %s unregistered\n",
 		       pDevice->dev->name, pDevice->apdev->name);
 	}
-	free_netdev(pDevice->apdev);
+	if (pDevice->apdev)
+		free_netdev(pDevice->apdev);
 	pDevice->apdev = NULL;
     pDevice->bEnable8021x = false;
     pDevice->bEnableHostWEP = false;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [patch] Staging: vt6655-6: potential NULL dereference in hostap_disable_hostapd()
  2013-11-07  7:55 [patch] Staging: vt6655-6: potential NULL dereference in hostap_disable_hostapd() Dan Carpenter
@ 2013-11-07  8:45 ` Waskiewicz Jr, Peter P
  2014-01-15  9:04 ` walter harms
  2014-01-15 10:14 ` Dan Carpenter
  2 siblings, 0 replies; 4+ messages in thread
From: Waskiewicz Jr, Peter P @ 2013-11-07  8:45 UTC (permalink / raw)
  To: kernel-janitors

T24gVGh1LCAyMDEzLTExLTA3IGF0IDEwOjU1ICswMzAwLCBEYW4gQ2FycGVudGVyIHdyb3RlOg0K
PiBXZSBmaXhlZCB0aGlzIHRvIHVzZSBmcmVlX25ldGRldigpIGluc3RlYWQgb2Yga2ZyZWUoKSBi
dXQgdW5mb3J0dW5hdGVseQ0KPiBmcmVlX25ldGRldigpIGRvZXNuJ3QgYWNjZXB0IE5VTEwgcG9p
bnRlcnMuICBTbWF0Y2ggY29tcGxhaW5zIGFib3V0DQo+IHRoaXMsIGl0J3Mgbm90IHNvbWV0aGlu
ZyBJIGRpc2NvdmVyZWQgdGhyb3VnaCB0ZXN0aW5nLg0KDQpXb3VsZG4ndCBhIGJldHRlciBhcHBy
b2FjaCBiZSB0byBjaGFuZ2UgZnJlZV9uZXRkZXYoKSB0byBhbGxvdyBpdCB0bw0KdGFrZSBOVUxM
IHBvaW50ZXJzPw0KDQotUEoNCg0KPiBGaXhlczogMzAzMGQ0MGI1MDM2ICgnc3RhZ2luZzogdnQ2
NjU1OiB1c2UgZnJlZV9uZXRkZXYgaW5zdGVhZCBvZiBrZnJlZScpDQo+IEZpeGVzOiAwYTQzOGQ1
YjM4MWUgKCdzdGFnaW5nOiB2dDY2NTY6IHVzZSBmcmVlX25ldGRldiBpbnN0ZWFkIG9mIGtmcmVl
JykNCj4gU2lnbmVkLW9mZi1ieTogR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NjQ0
DQo+IC0tLSBhL2RyaXZlcnMvc3RhZ2luZy92dDY2NTYvaG9zdGFwLmMNCj4gKysrIGIvZHJpdmVy
cy9zdGFnaW5nL3Z0NjY1Ni9ob3N0YXAuYw0KPiBAQCAtMTMzLDcgKzEzMyw4IEBAIHN0YXRpYyBp
bnQgaG9zdGFwX2Rpc2FibGVfaG9zdGFwZChzdHJ1Y3Qgdm50X3ByaXZhdGUgKnBEZXZpY2UsIGlu
dCBydG5sX2xvY2tlZCkNCj4gICAgICAgICAgICAgIERCR19QUlQoTVNHX0xFVkVMX0RFQlVHLCBL
RVJOX0lORk8gIiVzOiBOZXRkZXZpY2UgJXMgdW5yZWdpc3RlcmVkXG4iLA0KPiAgCQkgICAgICAg
cERldmljZS0+ZGV2LT5uYW1lLCBwRGV2aWNlLT5hcGRldi0+bmFtZSk7DQo+ICAJfQ0KPiAtCWZy
ZWVfbmV0ZGV2KHBEZXZpY2UtPmFwZGV2KTsNCj4gKwlpZiAocERldmljZS0+YXBkZXYpDQo+ICsJ
CWZyZWVfbmV0ZGV2KHBEZXZpY2UtPmFwZGV2KTsNCj4gIAlwRGV2aWNlLT5hcGRldiA9IE5VTEw7
DQo+ICAgICAgcERldmljZS0+YkVuYWJsZTgwMjF4ID0gZmFsc2U7DQo+ICAgICAgcERldmljZS0+
YkVuYWJsZUhvc3RXRVAgPSBmYWxzZTsNCg0K

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] Staging: vt6655-6: potential NULL dereference in hostap_disable_hostapd()
  2013-11-07  7:55 [patch] Staging: vt6655-6: potential NULL dereference in hostap_disable_hostapd() Dan Carpenter
  2013-11-07  8:45 ` Waskiewicz Jr, Peter P
@ 2014-01-15  9:04 ` walter harms
  2014-01-15 10:14 ` Dan Carpenter
  2 siblings, 0 replies; 4+ messages in thread
From: walter harms @ 2014-01-15  9:04 UTC (permalink / raw)
  To: kernel-janitors



Am 07.11.2013 08:55, schrieb Dan Carpenter:
> We fixed this to use free_netdev() instead of kfree() but unfortunately
> free_netdev() doesn't accept NULL pointers.  Smatch complains about
> this, it's not something I discovered through testing.
> 
> Fixes: 3030d40b5036 ('staging: vt6655: use free_netdev instead of kfree')
> Fixes: 0a438d5b381e ('staging: vt6656: use free_netdev instead of kfree')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
> index aab0012..ab8b2ba 100644
> --- a/drivers/staging/vt6655/hostap.c
> +++ b/drivers/staging/vt6655/hostap.c
> @@ -143,7 +143,8 @@ static int hostap_disable_hostapd(PSDevice pDevice, int rtnl_locked)
>  		DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Netdevice %s unregistered\n",
>  			pDevice->dev->name, pDevice->apdev->name);
>  	}
> -	free_netdev(pDevice->apdev);
> +	if (pDevice->apdev)
> +		free_netdev(pDevice->apdev);


perhaps the better way is to fix free_netdev() to make it behave like kfree() and friends.

just my 2 cents,
 wh

>  	pDevice->apdev = NULL;
>  	pDevice->bEnable8021x = false;
>  	pDevice->bEnableHostWEP = false;
> diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
> index ae1676d..67ba48b 100644
> --- a/drivers/staging/vt6656/hostap.c
> +++ b/drivers/staging/vt6656/hostap.c
> @@ -133,7 +133,8 @@ static int hostap_disable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
>              DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Netdevice %s unregistered\n",
>  		       pDevice->dev->name, pDevice->apdev->name);
>  	}
> -	free_netdev(pDevice->apdev);
> +	if (pDevice->apdev)
> +		free_netdev(pDevice->apdev);
>  	pDevice->apdev = NULL;
>      pDevice->bEnable8021x = false;
>      pDevice->bEnableHostWEP = false;
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] Staging: vt6655-6: potential NULL dereference in hostap_disable_hostapd()
  2013-11-07  7:55 [patch] Staging: vt6655-6: potential NULL dereference in hostap_disable_hostapd() Dan Carpenter
  2013-11-07  8:45 ` Waskiewicz Jr, Peter P
  2014-01-15  9:04 ` walter harms
@ 2014-01-15 10:14 ` Dan Carpenter
  2 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2014-01-15 10:14 UTC (permalink / raw)
  To: kernel-janitors

This patch was merged a long time ago, but we still could change
free_netdev() as well.  I say go for it!

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-01-15 10:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-07  7:55 [patch] Staging: vt6655-6: potential NULL dereference in hostap_disable_hostapd() Dan Carpenter
2013-11-07  8:45 ` Waskiewicz Jr, Peter P
2014-01-15  9:04 ` walter harms
2014-01-15 10:14 ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox