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: Bhumika Goyal <bhumirks@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
bb106dc0e2
commit
9155c92463
|
@ -56,7 +56,7 @@ int r8712_os_recvbuf_resource_alloc(struct _adapter *padapter,
|
|||
|
||||
precvbuf->irp_pending = false;
|
||||
precvbuf->purb = usb_alloc_urb(0, GFP_KERNEL);
|
||||
if (precvbuf->purb == NULL)
|
||||
if (!precvbuf->purb)
|
||||
res = _FAIL;
|
||||
precvbuf->pskb = NULL;
|
||||
precvbuf->reuse = false;
|
||||
|
|
|
@ -113,7 +113,7 @@ uint r8712_alloc_io_queue(struct _adapter *adapter)
|
|||
struct io_req *pio_req;
|
||||
|
||||
pio_queue = kmalloc(sizeof(*pio_queue), GFP_ATOMIC);
|
||||
if (pio_queue == NULL)
|
||||
if (!pio_queue)
|
||||
goto alloc_io_queue_fail;
|
||||
INIT_LIST_HEAD(&pio_queue->free_ioreqs);
|
||||
INIT_LIST_HEAD(&pio_queue->processing);
|
||||
|
|
|
@ -64,7 +64,7 @@ static sint _init_mlme_priv(struct _adapter *padapter)
|
|||
memset(&pmlmepriv->assoc_ssid, 0, sizeof(struct ndis_802_11_ssid));
|
||||
pbuf = kmalloc_array(MAX_BSS_CNT, sizeof(struct wlan_network),
|
||||
GFP_ATOMIC);
|
||||
if (pbuf == NULL)
|
||||
if (!pbuf)
|
||||
return _FAIL;
|
||||
pmlmepriv->free_bss_buf = pbuf;
|
||||
pnetwork = (struct wlan_network *)pbuf;
|
||||
|
@ -1202,7 +1202,7 @@ sint r8712_set_auth(struct _adapter *adapter,
|
|||
struct setauth_parm *psetauthparm;
|
||||
|
||||
pcmd = kmalloc(sizeof(*pcmd), GFP_ATOMIC);
|
||||
if (pcmd == NULL)
|
||||
if (!pcmd)
|
||||
return _FAIL;
|
||||
|
||||
psetauthparm = kzalloc(sizeof(*psetauthparm), GFP_ATOMIC);
|
||||
|
@ -1232,7 +1232,7 @@ sint r8712_set_key(struct _adapter *adapter,
|
|||
sint ret = _SUCCESS;
|
||||
|
||||
pcmd = kmalloc(sizeof(*pcmd), GFP_ATOMIC);
|
||||
if (pcmd == NULL)
|
||||
if (!pcmd)
|
||||
return _FAIL;
|
||||
psetkeyparm = kzalloc(sizeof(*psetkeyparm), GFP_ATOMIC);
|
||||
if (psetkeyparm == NULL) {
|
||||
|
|
|
@ -281,10 +281,10 @@ void r8712_SetChannel(struct _adapter *pAdapter)
|
|||
u16 code = GEN_CMD_CODE(_SetChannel);
|
||||
|
||||
pcmd = kmalloc(sizeof(*pcmd), GFP_ATOMIC);
|
||||
if (pcmd == NULL)
|
||||
if (!pcmd)
|
||||
return;
|
||||
pparm = kmalloc(sizeof(*pparm), GFP_ATOMIC);
|
||||
if (pparm == NULL) {
|
||||
if (!pparm) {
|
||||
kfree(pcmd);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ u32 _r8712_init_sta_priv(struct sta_priv *pstapriv)
|
|||
|
||||
pstapriv->pallocated_stainfo_buf = kmalloc(sizeof(struct sta_info) *
|
||||
NUM_STA + 4, GFP_ATOMIC);
|
||||
if (pstapriv->pallocated_stainfo_buf == NULL)
|
||||
if (!pstapriv->pallocated_stainfo_buf)
|
||||
return _FAIL;
|
||||
pstapriv->pstainfo_buf = pstapriv->pallocated_stainfo_buf + 4 -
|
||||
((addr_t)(pstapriv->pallocated_stainfo_buf) & 3);
|
||||
|
|
|
@ -89,7 +89,7 @@ sint _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv,
|
|||
*/
|
||||
pxmitpriv->pallocated_frame_buf = kmalloc(NR_XMITFRAME * sizeof(struct xmit_frame) + 4,
|
||||
GFP_ATOMIC);
|
||||
if (pxmitpriv->pallocated_frame_buf == NULL) {
|
||||
if (!pxmitpriv->pallocated_frame_buf) {
|
||||
pxmitpriv->pxmit_frame_buf = NULL;
|
||||
return _FAIL;
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ sint _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv,
|
|||
_init_queue(&pxmitpriv->pending_xmitbuf_queue);
|
||||
pxmitpriv->pallocated_xmitbuf = kmalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4,
|
||||
GFP_ATOMIC);
|
||||
if (pxmitpriv->pallocated_xmitbuf == NULL)
|
||||
if (!pxmitpriv->pallocated_xmitbuf)
|
||||
return _FAIL;
|
||||
pxmitpriv->pxmitbuf = pxmitpriv->pallocated_xmitbuf + 4 -
|
||||
((addr_t)(pxmitpriv->pallocated_xmitbuf) & 3);
|
||||
|
@ -137,7 +137,7 @@ sint _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv,
|
|||
INIT_LIST_HEAD(&pxmitbuf->list);
|
||||
pxmitbuf->pallocated_buf = kmalloc(MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ,
|
||||
GFP_ATOMIC);
|
||||
if (pxmitbuf->pallocated_buf == NULL)
|
||||
if (!pxmitbuf->pallocated_buf)
|
||||
return _FAIL;
|
||||
pxmitbuf->pbuf = pxmitbuf->pallocated_buf + XMITBUF_ALIGN_SZ -
|
||||
((addr_t) (pxmitbuf->pallocated_buf) &
|
||||
|
@ -943,7 +943,7 @@ static void alloc_hwxmits(struct _adapter *padapter)
|
|||
pxmitpriv->hwxmit_entry = HWXMIT_ENTRY;
|
||||
pxmitpriv->hwxmits = kmalloc_array(pxmitpriv->hwxmit_entry,
|
||||
sizeof(struct hw_xmit), GFP_ATOMIC);
|
||||
if (pxmitpriv->hwxmits == NULL)
|
||||
if (!pxmitpriv->hwxmits)
|
||||
return;
|
||||
hwxmits = pxmitpriv->hwxmits;
|
||||
if (pxmitpriv->hwxmit_entry == 5) {
|
||||
|
|
Loading…
Reference in New Issue