Commit 8362cd41 authored by Dan Williams's avatar Dan Williams Committed by David S. Miller

[PATCH] libertas: fix sparse-reported problems

A few fields being converted to the wrong sized type, and a few missed
endian conversions.
Signed-off-by: default avatarDan Williams <dcbw@redhat.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent c7fdf269
...@@ -543,7 +543,7 @@ int libertas_cmd_802_11d_domain_info(wlan_private * priv, ...@@ -543,7 +543,7 @@ int libertas_cmd_802_11d_domain_info(wlan_private * priv,
nr_subband * sizeof(struct ieeetypes_subbandset)); nr_subband * sizeof(struct ieeetypes_subbandset));
cmd->size = cpu_to_le16(sizeof(pdomaininfo->action) + cmd->size = cpu_to_le16(sizeof(pdomaininfo->action) +
domain->header.len + le16_to_cpu(domain->header.len) +
sizeof(struct mrvlietypesheader) + sizeof(struct mrvlietypesheader) +
S_DS_GEN); S_DS_GEN);
} else { } else {
......
...@@ -812,8 +812,8 @@ int libertas_process_rx_command(wlan_private * priv) ...@@ -812,8 +812,8 @@ int libertas_process_rx_command(wlan_private * priv)
if (adapter->cur_cmd->cmdflags & CMD_F_HOSTCMD) { if (adapter->cur_cmd->cmdflags & CMD_F_HOSTCMD) {
/* Copy the response back to response buffer */ /* Copy the response back to response buffer */
memcpy(adapter->cur_cmd->pdata_buf, resp, resp->size); memcpy(adapter->cur_cmd->pdata_buf, resp,
le16_to_cpu(resp->size));
adapter->cur_cmd->cmdflags &= ~CMD_F_HOSTCMD; adapter->cur_cmd->cmdflags &= ~CMD_F_HOSTCMD;
} }
......
...@@ -510,7 +510,7 @@ static u16 libertas_get_events_bitmap(wlan_private *priv) ...@@ -510,7 +510,7 @@ static u16 libertas_get_events_bitmap(wlan_private *priv)
return 0; return 0;
} }
if (pcmdptr->command != CMD_RET(CMD_802_11_SUBSCRIBE_EVENT)) { if (le16_to_cpu(pcmdptr->command) != CMD_RET(CMD_802_11_SUBSCRIBE_EVENT)) {
lbs_pr_err("command response incorrect!\n"); lbs_pr_err("command response incorrect!\n");
kfree(response_buf); kfree(response_buf);
return 0; return 0;
......
...@@ -639,11 +639,13 @@ static void if_usb_receive(struct urb *urb) ...@@ -639,11 +639,13 @@ static void if_usb_receive(struct urb *urb)
int recvlength = urb->actual_length; int recvlength = urb->actual_length;
u8 *recvbuff = NULL; u8 *recvbuff = NULL;
u32 recvtype; u32 recvtype = 0;
lbs_deb_enter(LBS_DEB_USB); lbs_deb_enter(LBS_DEB_USB);
if (recvlength) { if (recvlength) {
__le32 tmp;
if (urb->status) { if (urb->status) {
lbs_deb_usbd(&cardp->udev->dev, lbs_deb_usbd(&cardp->udev->dev,
"URB status is failed\n"); "URB status is failed\n");
...@@ -652,18 +654,14 @@ static void if_usb_receive(struct urb *urb) ...@@ -652,18 +654,14 @@ static void if_usb_receive(struct urb *urb)
} }
recvbuff = skb->data + IPFIELD_ALIGN_OFFSET; recvbuff = skb->data + IPFIELD_ALIGN_OFFSET;
memcpy(&recvtype, recvbuff, sizeof(u32)); memcpy(&tmp, recvbuff, sizeof(u32));
lbs_deb_usbd(&cardp->udev->dev, recvtype = le32_to_cpu(tmp);
"Recv length = 0x%x\n", recvlength);
lbs_deb_usbd(&cardp->udev->dev, lbs_deb_usbd(&cardp->udev->dev,
"Receive type = 0x%X\n", recvtype); "Recv length = 0x%x, Recv type = 0x%X\n",
recvtype = le32_to_cpu(recvtype); recvlength, recvtype);
lbs_deb_usbd(&cardp->udev->dev,
"Receive type after = 0x%X\n", recvtype);
} else if (urb->status) } else if (urb->status)
goto rx_exit; goto rx_exit;
switch (recvtype) { switch (recvtype) {
case CMD_TYPE_DATA: case CMD_TYPE_DATA:
process_cmdtypedata(recvlength, skb, cardp, priv); process_cmdtypedata(recvlength, skb, cardp, priv);
...@@ -691,6 +689,8 @@ static void if_usb_receive(struct urb *urb) ...@@ -691,6 +689,8 @@ static void if_usb_receive(struct urb *urb)
spin_unlock(&priv->adapter->driver_lock); spin_unlock(&priv->adapter->driver_lock);
goto rx_exit; goto rx_exit;
default: default:
lbs_deb_usbd(&cardp->udev->dev, "Unknown command type 0x%X\n",
recvtype);
kfree_skb(skb); kfree_skb(skb);
break; break;
} }
...@@ -711,21 +711,19 @@ rx_exit: ...@@ -711,21 +711,19 @@ rx_exit:
*/ */
static int if_usb_host_to_card(wlan_private * priv, u8 type, u8 * payload, u16 nb) static int if_usb_host_to_card(wlan_private * priv, u8 type, u8 * payload, u16 nb)
{ {
int ret = -1;
u32 tmp;
struct usb_card_rec *cardp = (struct usb_card_rec *)priv->card; struct usb_card_rec *cardp = (struct usb_card_rec *)priv->card;
lbs_deb_usbd(&cardp->udev->dev,"*** type = %u\n", type); lbs_deb_usbd(&cardp->udev->dev,"*** type = %u\n", type);
lbs_deb_usbd(&cardp->udev->dev,"size after = %d\n", nb); lbs_deb_usbd(&cardp->udev->dev,"size after = %d\n", nb);
if (type == MVMS_CMD) { if (type == MVMS_CMD) {
tmp = cpu_to_le32(CMD_TYPE_REQUEST); __le32 tmp = cpu_to_le32(CMD_TYPE_REQUEST);
priv->dnld_sent = DNLD_CMD_SENT; priv->dnld_sent = DNLD_CMD_SENT;
memcpy(cardp->bulk_out_buffer, (u8 *) & tmp, memcpy(cardp->bulk_out_buffer, (u8 *) & tmp,
MESSAGE_HEADER_LEN); MESSAGE_HEADER_LEN);
} else { } else {
tmp = cpu_to_le32(CMD_TYPE_DATA); __le32 tmp = cpu_to_le32(CMD_TYPE_DATA);
priv->dnld_sent = DNLD_DATA_SENT; priv->dnld_sent = DNLD_DATA_SENT;
memcpy(cardp->bulk_out_buffer, (u8 *) & tmp, memcpy(cardp->bulk_out_buffer, (u8 *) & tmp,
MESSAGE_HEADER_LEN); MESSAGE_HEADER_LEN);
...@@ -733,10 +731,8 @@ static int if_usb_host_to_card(wlan_private * priv, u8 type, u8 * payload, u16 n ...@@ -733,10 +731,8 @@ static int if_usb_host_to_card(wlan_private * priv, u8 type, u8 * payload, u16 n
memcpy((cardp->bulk_out_buffer + MESSAGE_HEADER_LEN), payload, nb); memcpy((cardp->bulk_out_buffer + MESSAGE_HEADER_LEN), payload, nb);
ret = return usb_tx_block(priv, cardp->bulk_out_buffer,
usb_tx_block(priv, cardp->bulk_out_buffer, nb + MESSAGE_HEADER_LEN); nb + MESSAGE_HEADER_LEN);
return ret;
} }
/* called with adapter->driver_lock held */ /* called with adapter->driver_lock held */
......
...@@ -370,8 +370,8 @@ static int process_rxed_802_11_packet(wlan_private * priv, struct sk_buff *skb) ...@@ -370,8 +370,8 @@ static int process_rxed_802_11_packet(wlan_private * priv, struct sk_buff *skb)
radiotap_hdr.hdr.it_version = 0; radiotap_hdr.hdr.it_version = 0;
/* XXX must check this value for pad */ /* XXX must check this value for pad */
radiotap_hdr.hdr.it_pad = 0; radiotap_hdr.hdr.it_pad = 0;
radiotap_hdr.hdr.it_len = sizeof(struct rx_radiotap_hdr); radiotap_hdr.hdr.it_len = cpu_to_le16 (sizeof(struct rx_radiotap_hdr));
radiotap_hdr.hdr.it_present = RX_RADIOTAP_PRESENT; radiotap_hdr.hdr.it_present = cpu_to_le32 (RX_RADIOTAP_PRESENT);
/* unknown values */ /* unknown values */
radiotap_hdr.flags = 0; radiotap_hdr.flags = 0;
radiotap_hdr.chan_freq = 0; radiotap_hdr.chan_freq = 0;
......
...@@ -872,7 +872,7 @@ static struct iw_statistics *wlan_get_wireless_stats(struct net_device *dev) ...@@ -872,7 +872,7 @@ static struct iw_statistics *wlan_get_wireless_stats(struct net_device *dev)
/* Quality by TX errors */ /* Quality by TX errors */
priv->wstats.discard.retries = priv->stats.tx_errors; priv->wstats.discard.retries = priv->stats.tx_errors;
tx_retries = le16_to_cpu(adapter->logmsg.retry); tx_retries = le32_to_cpu(adapter->logmsg.retry);
if (tx_retries > 75) if (tx_retries > 75)
tx_qual = (90 - tx_retries) * POOR / 15; tx_qual = (90 - tx_retries) * POOR / 15;
...@@ -888,10 +888,10 @@ static struct iw_statistics *wlan_get_wireless_stats(struct net_device *dev) ...@@ -888,10 +888,10 @@ static struct iw_statistics *wlan_get_wireless_stats(struct net_device *dev)
(PERFECT - VERY_GOOD) / 50 + VERY_GOOD; (PERFECT - VERY_GOOD) / 50 + VERY_GOOD;
quality = min(quality, tx_qual); quality = min(quality, tx_qual);
priv->wstats.discard.code = le16_to_cpu(adapter->logmsg.wepundecryptable); priv->wstats.discard.code = le32_to_cpu(adapter->logmsg.wepundecryptable);
priv->wstats.discard.fragment = le16_to_cpu(adapter->logmsg.rxfrag); priv->wstats.discard.fragment = le32_to_cpu(adapter->logmsg.rxfrag);
priv->wstats.discard.retries = tx_retries; priv->wstats.discard.retries = tx_retries;
priv->wstats.discard.misc = le16_to_cpu(adapter->logmsg.ackfailure); priv->wstats.discard.misc = le32_to_cpu(adapter->logmsg.ackfailure);
/* Calculate quality */ /* Calculate quality */
priv->wstats.qual.qual = min_t(u8, quality, 100); priv->wstats.qual.qual = min_t(u8, quality, 100);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment