Commit 9155c924 authored by Bhumika Goyal's avatar Bhumika Goyal Committed by Greg Kroah-Hartman
Browse files

Staging: rtl8712: Clean up tests if NULL returned on failure



Some functions like kmalloc/usb_alloc_urb/kmalloc_array returns NULL as
their return value on failure. !x is generally preferred over x==NULL
or NULL==x so make use of !x if the value returned on failure
by these functions is NULL.
Done using coccinelle:

@@
expression e;
statement S;
@@
e = \(kmalloc\|devm_kzalloc\|kmalloc_array
     \|devm_ioremap\|usb_alloc_urb\|alloc_netdev\)(...);
- if(e==NULL)
+ if(!e)
  S

Signed-off-by: default avatarBhumika Goyal <bhumirks@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent bb106dc0
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -56,7 +56,7 @@ int r8712_os_recvbuf_resource_alloc(struct _adapter *padapter,


	precvbuf->irp_pending = false;
	precvbuf->irp_pending = false;
	precvbuf->purb = usb_alloc_urb(0, GFP_KERNEL);
	precvbuf->purb = usb_alloc_urb(0, GFP_KERNEL);
	if (precvbuf->purb == NULL)
	if (!precvbuf->purb)
		res = _FAIL;
		res = _FAIL;
	precvbuf->pskb = NULL;
	precvbuf->pskb = NULL;
	precvbuf->reuse = false;
	precvbuf->reuse = false;
+1 −1
Original line number Original line Diff line number Diff line
@@ -113,7 +113,7 @@ uint r8712_alloc_io_queue(struct _adapter *adapter)
	struct io_req *pio_req;
	struct io_req *pio_req;


	pio_queue = kmalloc(sizeof(*pio_queue), GFP_ATOMIC);
	pio_queue = kmalloc(sizeof(*pio_queue), GFP_ATOMIC);
	if (pio_queue == NULL)
	if (!pio_queue)
		goto alloc_io_queue_fail;
		goto alloc_io_queue_fail;
	INIT_LIST_HEAD(&pio_queue->free_ioreqs);
	INIT_LIST_HEAD(&pio_queue->free_ioreqs);
	INIT_LIST_HEAD(&pio_queue->processing);
	INIT_LIST_HEAD(&pio_queue->processing);
+3 −3
Original line number Original line Diff line number Diff line
@@ -64,7 +64,7 @@ static sint _init_mlme_priv(struct _adapter *padapter)
	memset(&pmlmepriv->assoc_ssid, 0, sizeof(struct ndis_802_11_ssid));
	memset(&pmlmepriv->assoc_ssid, 0, sizeof(struct ndis_802_11_ssid));
	pbuf = kmalloc_array(MAX_BSS_CNT, sizeof(struct wlan_network),
	pbuf = kmalloc_array(MAX_BSS_CNT, sizeof(struct wlan_network),
			     GFP_ATOMIC);
			     GFP_ATOMIC);
	if (pbuf == NULL)
	if (!pbuf)
		return _FAIL;
		return _FAIL;
	pmlmepriv->free_bss_buf = pbuf;
	pmlmepriv->free_bss_buf = pbuf;
	pnetwork = (struct wlan_network *)pbuf;
	pnetwork = (struct wlan_network *)pbuf;
@@ -1202,7 +1202,7 @@ sint r8712_set_auth(struct _adapter *adapter,
	struct setauth_parm *psetauthparm;
	struct setauth_parm *psetauthparm;


	pcmd = kmalloc(sizeof(*pcmd), GFP_ATOMIC);
	pcmd = kmalloc(sizeof(*pcmd), GFP_ATOMIC);
	if (pcmd == NULL)
	if (!pcmd)
		return _FAIL;
		return _FAIL;


	psetauthparm = kzalloc(sizeof(*psetauthparm), GFP_ATOMIC);
	psetauthparm = kzalloc(sizeof(*psetauthparm), GFP_ATOMIC);
@@ -1232,7 +1232,7 @@ sint r8712_set_key(struct _adapter *adapter,
	sint ret = _SUCCESS;
	sint ret = _SUCCESS;


	pcmd = kmalloc(sizeof(*pcmd), GFP_ATOMIC);
	pcmd = kmalloc(sizeof(*pcmd), GFP_ATOMIC);
	if (pcmd == NULL)
	if (!pcmd)
		return _FAIL;
		return _FAIL;
	psetkeyparm = kzalloc(sizeof(*psetkeyparm), GFP_ATOMIC);
	psetkeyparm = kzalloc(sizeof(*psetkeyparm), GFP_ATOMIC);
	if (psetkeyparm == NULL) {
	if (psetkeyparm == NULL) {
+2 −2
Original line number Original line Diff line number Diff line
@@ -281,10 +281,10 @@ void r8712_SetChannel(struct _adapter *pAdapter)
	u16 code = GEN_CMD_CODE(_SetChannel);
	u16 code = GEN_CMD_CODE(_SetChannel);


	pcmd = kmalloc(sizeof(*pcmd), GFP_ATOMIC);
	pcmd = kmalloc(sizeof(*pcmd), GFP_ATOMIC);
	if (pcmd == NULL)
	if (!pcmd)
		return;
		return;
	pparm = kmalloc(sizeof(*pparm), GFP_ATOMIC);
	pparm = kmalloc(sizeof(*pparm), GFP_ATOMIC);
	if (pparm == NULL) {
	if (!pparm) {
		kfree(pcmd);
		kfree(pcmd);
		return;
		return;
	}
	}
+1 −1
Original line number Original line Diff line number Diff line
@@ -53,7 +53,7 @@ u32 _r8712_init_sta_priv(struct sta_priv *pstapriv)


	pstapriv->pallocated_stainfo_buf = kmalloc(sizeof(struct sta_info) *
	pstapriv->pallocated_stainfo_buf = kmalloc(sizeof(struct sta_info) *
						   NUM_STA + 4, GFP_ATOMIC);
						   NUM_STA + 4, GFP_ATOMIC);
	if (pstapriv->pallocated_stainfo_buf == NULL)
	if (!pstapriv->pallocated_stainfo_buf)
		return _FAIL;
		return _FAIL;
	pstapriv->pstainfo_buf = pstapriv->pallocated_stainfo_buf + 4 -
	pstapriv->pstainfo_buf = pstapriv->pallocated_stainfo_buf + 4 -
		((addr_t)(pstapriv->pallocated_stainfo_buf) & 3);
		((addr_t)(pstapriv->pallocated_stainfo_buf) & 3);
Loading