Skip to content

Commit 4c4af69

Browse files
Marek Lindnersimonwunderlich
authored andcommitted
batman-adv: fix hardif_neigh refcount on queue_work() failure
The hardif_neigh refcounter is to be decreased by the queued work and currently is never decreased if the queue_work() call fails. Fix by checking the queue_work() return value and decrease refcount if necessary. Signed-off-by: Marek Lindner <[email protected]> Signed-off-by: Sven Eckelmann <[email protected]> Signed-off-by: Simon Wunderlich <[email protected]>
1 parent 5af96b9 commit 4c4af69

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

net/batman-adv/bat_v_elp.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ static void batadv_v_elp_periodic_work(struct work_struct *work)
268268
struct batadv_priv *bat_priv;
269269
struct sk_buff *skb;
270270
u32 elp_interval;
271+
bool ret;
271272

272273
bat_v = container_of(work, struct batadv_hard_iface_bat_v, elp_wq.work);
273274
hard_iface = container_of(bat_v, struct batadv_hard_iface, bat_v);
@@ -329,8 +330,11 @@ static void batadv_v_elp_periodic_work(struct work_struct *work)
329330
* may sleep and that is not allowed in an rcu protected
330331
* context. Therefore schedule a task for that.
331332
*/
332-
queue_work(batadv_event_workqueue,
333-
&hardif_neigh->bat_v.metric_work);
333+
ret = queue_work(batadv_event_workqueue,
334+
&hardif_neigh->bat_v.metric_work);
335+
336+
if (!ret)
337+
batadv_hardif_neigh_put(hardif_neigh);
334338
}
335339
rcu_read_unlock();
336340

0 commit comments

Comments
 (0)