3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-30 14:22:37 +01:00

netdev: Reorder the registered check in netdev_frame_watch_add

The l_queue_find() to find other watches matching the new prefix
needs to be before the watchlist_link(), otherwise the prefix will
match itself and "registered" is always true.
This commit is contained in:
Andrew Zaborowski 2017-09-07 23:04:44 +02:00 committed by Denis Kenzior
parent f2c4969fc9
commit 509324666c

View File

@ -3239,6 +3239,10 @@ uint32_t netdev_frame_watch_add(struct netdev *netdev, uint16_t frame_type,
bool registered; bool registered;
uint32_t id; uint32_t id;
registered = l_queue_find(netdev->frame_watches.items,
netdev_frame_watch_match_prefix,
&info);
fw = l_new(struct netdev_frame_watch, 1); fw = l_new(struct netdev_frame_watch, 1);
fw->frame_type = frame_type; fw->frame_type = frame_type;
fw->prefix = l_memdup(prefix, prefix_len); fw->prefix = l_memdup(prefix, prefix_len);
@ -3246,10 +3250,6 @@ uint32_t netdev_frame_watch_add(struct netdev *netdev, uint16_t frame_type,
id = watchlist_link(&netdev->frame_watches, &fw->super, id = watchlist_link(&netdev->frame_watches, &fw->super,
handler, user_data, NULL); handler, user_data, NULL);
registered = l_queue_find(netdev->frame_watches.items,
netdev_frame_watch_match_prefix,
&info);
if (registered) if (registered)
return id; return id;