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
1 changed files with 4 additions and 4 deletions

View File

@ -3239,6 +3239,10 @@ uint32_t netdev_frame_watch_add(struct netdev *netdev, uint16_t frame_type,
bool registered;
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->frame_type = frame_type;
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,
handler, user_data, NULL);
registered = l_queue_find(netdev->frame_watches.items,
netdev_frame_watch_match_prefix,
&info);
if (registered)
return id;