From: Paul E. McKenney Date: Tue, 31 Jul 2007 07:38:48 +0000 (-0700) Subject: bpqether: fix rcu usage X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b34bd06e485abf5b24fc13a9a988ebf4d2915dd6;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git bpqether: fix rcu usage The rcu_dereference() primitive needs to be applied to an l-value in order to ensure that compiler writers don't get an opportunity to apply reordering optimizations that could result in multiple fetches or in other misbehavior. This patch pulls the rcu_dereference() calls in bpq_seq_next() up to the point at which the fetched pointers are still l-values, rather than after list_entry() has transformed them into r-values. Signed-off-by: Paul E. McKenney Cc: Jeff Garzik Cc: Ralf Baechle Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c index 656f2789c9ba..cc0ee93669ea 100644 --- a/drivers/net/hamradio/bpqether.c +++ b/drivers/net/hamradio/bpqether.c @@ -413,12 +413,12 @@ static void *bpq_seq_next(struct seq_file *seq, void *v, loff_t *pos) ++*pos; if (v == SEQ_START_TOKEN) - p = bpq_devices.next; + p = rcu_dereference(bpq_devices.next); else - p = ((struct bpqdev *)v)->bpq_list.next; + p = rcu_dereference(((struct bpqdev *)v)->bpq_list.next); return (p == &bpq_devices) ? NULL - : rcu_dereference(list_entry(p, struct bpqdev, bpq_list)); + : list_entry(p, struct bpqdev, bpq_list); } static void bpq_seq_stop(struct seq_file *seq, void *v)