1
0
Fork 0

mac80211_hwsim: fix smatch/sparse complaints

The code is fine in both cases as-is, but we can
write it slightly differently to fix smatch/sparse
complaints:
 * compare the skb pointer (which we use as a cookie)
   by casting the skb to unsigned long rather than the
   cookie to a pointer (fixes "different address spaces")
 * when transmitting, data->channel must be assigned,
   don't check it (fixes "dereferenced before check")

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
hifive-unleashed-5.1
Johannes Berg 2012-06-25 14:46:44 +02:00
parent 3fae027316
commit d0f718c1c0
1 changed files with 4 additions and 6 deletions

View File

@ -678,8 +678,7 @@ static bool mac80211_hwsim_tx_frame_no_nl(struct ieee80211_hw *hw,
continue; continue;
if (data2->idle || !data2->started || if (data2->idle || !data2->started ||
!hwsim_ps_rx_ok(data2, skb) || !hwsim_ps_rx_ok(data2, skb) || !data2->channel ||
!data->channel || !data2->channel ||
data->channel->center_freq != data2->channel->center_freq || data->channel->center_freq != data2->channel->center_freq ||
!(data->group & data2->group)) !(data->group & data2->group))
continue; continue;
@ -1486,7 +1485,7 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2,
struct mac80211_hwsim_data *data2; struct mac80211_hwsim_data *data2;
struct ieee80211_tx_info *txi; struct ieee80211_tx_info *txi;
struct hwsim_tx_rate *tx_attempts; struct hwsim_tx_rate *tx_attempts;
struct sk_buff __user *ret_skb; unsigned long ret_skb_ptr;
struct sk_buff *skb, *tmp; struct sk_buff *skb, *tmp;
struct mac_address *src; struct mac_address *src;
unsigned int hwsim_flags; unsigned int hwsim_flags;
@ -1504,8 +1503,7 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2,
info->attrs[HWSIM_ATTR_ADDR_TRANSMITTER]); info->attrs[HWSIM_ATTR_ADDR_TRANSMITTER]);
hwsim_flags = nla_get_u32(info->attrs[HWSIM_ATTR_FLAGS]); hwsim_flags = nla_get_u32(info->attrs[HWSIM_ATTR_FLAGS]);
ret_skb = (struct sk_buff __user *) ret_skb_ptr = nla_get_u64(info->attrs[HWSIM_ATTR_COOKIE]);
(unsigned long) nla_get_u64(info->attrs[HWSIM_ATTR_COOKIE]);
data2 = get_hwsim_data_ref_from_addr(src); data2 = get_hwsim_data_ref_from_addr(src);
@ -1514,7 +1512,7 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2,
/* look for the skb matching the cookie passed back from user */ /* look for the skb matching the cookie passed back from user */
skb_queue_walk_safe(&data2->pending, skb, tmp) { skb_queue_walk_safe(&data2->pending, skb, tmp) {
if (skb == ret_skb) { if ((unsigned long)skb == ret_skb_ptr) {
skb_unlink(skb, &data2->pending); skb_unlink(skb, &data2->pending);
found = true; found = true;
break; break;