mirror of
https://github.com/lwfinger/rtl8188eu.git
synced 2024-11-25 05:53:41 +00:00
rtl8188eu: Fix smatch warning in hal/usb_ops_linux.c
Smatch shows the following: CHECK /home/finger/rtl8188eu/hal/usb_ops_linux.c /home/finger/rtl8188eu/hal/usb_ops_linux.c:630 usb_read_port() warn: variable dereferenced before check 'precvbuf' (see line 627) The code is refactored. Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
This commit is contained in:
parent
158597dcdd
commit
4749e2c19e
1 changed files with 48 additions and 49 deletions
|
@ -614,6 +614,11 @@ static u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem)
|
||||||
|
|
||||||
_func_enter_;
|
_func_enter_;
|
||||||
|
|
||||||
|
if (!precvbuf) {
|
||||||
|
RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
|
||||||
|
("usb_read_port:precvbuf ==NULL\n"));
|
||||||
|
return _FAIL;
|
||||||
|
}
|
||||||
if (adapter->bDriverStopped || adapter->bSurpriseRemoved ||
|
if (adapter->bDriverStopped || adapter->bSurpriseRemoved ||
|
||||||
adapter->pwrctrlpriv.pnp_bstop_trx) {
|
adapter->pwrctrlpriv.pnp_bstop_trx) {
|
||||||
RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
|
RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
|
||||||
|
@ -627,66 +632,60 @@ _func_enter_;
|
||||||
precvbuf->reuse = true;
|
precvbuf->reuse = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (precvbuf != NULL) {
|
rtl8188eu_init_recvbuf(adapter, precvbuf);
|
||||||
rtl8188eu_init_recvbuf(adapter, precvbuf);
|
|
||||||
|
|
||||||
/* re-assign for linux based on skb */
|
/* re-assign for linux based on skb */
|
||||||
if ((!precvbuf->reuse) || (precvbuf->pskb == NULL)) {
|
if ((!precvbuf->reuse) || (precvbuf->pskb == NULL)) {
|
||||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18))
|
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18))
|
||||||
precvbuf->pskb = dev_alloc_skb(MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ);
|
precvbuf->pskb = dev_alloc_skb(MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ);
|
||||||
#else
|
#else
|
||||||
precvbuf->pskb = netdev_alloc_skb(adapter->pnetdev, MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ);
|
precvbuf->pskb = netdev_alloc_skb(adapter->pnetdev, MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ);
|
||||||
#endif
|
#endif
|
||||||
if (precvbuf->pskb == NULL) {
|
if (precvbuf->pskb == NULL) {
|
||||||
RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("init_recvbuf(): alloc_skb fail!\n"));
|
RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("init_recvbuf(): alloc_skb fail!\n"));
|
||||||
DBG_88E("#### usb_read_port() alloc_skb fail!#####\n");
|
DBG_88E("#### usb_read_port() alloc_skb fail!#####\n");
|
||||||
return _FAIL;
|
return _FAIL;
|
||||||
}
|
|
||||||
|
|
||||||
tmpaddr = (size_t)precvbuf->pskb->data;
|
|
||||||
alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1);
|
|
||||||
skb_reserve(precvbuf->pskb, (RECVBUFF_ALIGN_SZ - alignment));
|
|
||||||
|
|
||||||
precvbuf->phead = precvbuf->pskb->head;
|
|
||||||
precvbuf->pdata = precvbuf->pskb->data;
|
|
||||||
precvbuf->ptail = skb_tail_pointer(precvbuf->pskb);
|
|
||||||
precvbuf->pend = skb_end_pointer(precvbuf->pskb);
|
|
||||||
precvbuf->pbuf = precvbuf->pskb->data;
|
|
||||||
} else { /* reuse skb */
|
|
||||||
precvbuf->phead = precvbuf->pskb->head;
|
|
||||||
precvbuf->pdata = precvbuf->pskb->data;
|
|
||||||
precvbuf->ptail = skb_tail_pointer(precvbuf->pskb);
|
|
||||||
precvbuf->pend = skb_end_pointer(precvbuf->pskb);
|
|
||||||
precvbuf->pbuf = precvbuf->pskb->data;
|
|
||||||
|
|
||||||
precvbuf->reuse = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
precvpriv->rx_pending_cnt++;
|
tmpaddr = (size_t)precvbuf->pskb->data;
|
||||||
|
alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1);
|
||||||
|
skb_reserve(precvbuf->pskb, (RECVBUFF_ALIGN_SZ - alignment));
|
||||||
|
|
||||||
purb = precvbuf->purb;
|
precvbuf->phead = precvbuf->pskb->head;
|
||||||
|
precvbuf->pdata = precvbuf->pskb->data;
|
||||||
|
precvbuf->ptail = skb_tail_pointer(precvbuf->pskb);
|
||||||
|
precvbuf->pend = skb_end_pointer(precvbuf->pskb);
|
||||||
|
precvbuf->pbuf = precvbuf->pskb->data;
|
||||||
|
} else { /* reuse skb */
|
||||||
|
precvbuf->phead = precvbuf->pskb->head;
|
||||||
|
precvbuf->pdata = precvbuf->pskb->data;
|
||||||
|
precvbuf->ptail = skb_tail_pointer(precvbuf->pskb);
|
||||||
|
precvbuf->pend = skb_end_pointer(precvbuf->pskb);
|
||||||
|
precvbuf->pbuf = precvbuf->pskb->data;
|
||||||
|
|
||||||
/* translate DMA FIFO addr to pipehandle */
|
precvbuf->reuse = false;
|
||||||
pipe = ffaddr2pipehdl(pdvobj, addr);
|
}
|
||||||
|
|
||||||
usb_fill_bulk_urb(purb, pusbd, pipe,
|
precvpriv->rx_pending_cnt++;
|
||||||
precvbuf->pbuf,
|
|
||||||
MAX_RECVBUF_SZ,
|
|
||||||
usb_read_port_complete,
|
|
||||||
precvbuf);/* context is precvbuf */
|
|
||||||
|
|
||||||
err = usb_submit_urb(purb, GFP_ATOMIC);
|
purb = precvbuf->purb;
|
||||||
if ((err) && (err != (-EPERM))) {
|
|
||||||
RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
|
/* translate DMA FIFO addr to pipehandle */
|
||||||
("cannot submit rx in-token(err=0x%.8x), URB_STATUS =0x%.8x",
|
pipe = ffaddr2pipehdl(pdvobj, addr);
|
||||||
err, purb->status));
|
|
||||||
DBG_88E("cannot submit rx in-token(err = 0x%08x),urb_status = %d\n",
|
usb_fill_bulk_urb(purb, pusbd, pipe,
|
||||||
err, purb->status);
|
precvbuf->pbuf,
|
||||||
ret = _FAIL;
|
MAX_RECVBUF_SZ,
|
||||||
}
|
usb_read_port_complete,
|
||||||
} else {
|
precvbuf);/* context is precvbuf */
|
||||||
|
|
||||||
|
err = usb_submit_urb(purb, GFP_ATOMIC);
|
||||||
|
if ((err) && (err != (-EPERM))) {
|
||||||
RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
|
RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
|
||||||
("usb_read_port:precvbuf ==NULL\n"));
|
("cannot submit rx in-token(err=0x%.8x), URB_STATUS =0x%.8x",
|
||||||
|
err, purb->status));
|
||||||
|
DBG_88E("cannot submit rx in-token(err = 0x%08x),urb_status = %d\n",
|
||||||
|
err, purb->status);
|
||||||
ret = _FAIL;
|
ret = _FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue