diff options
author | Kees Cook <keescook@chromium.org> | 2017-05-08 18:31:44 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-05-09 09:39:49 -0400 |
commit | f92ceb01c2cad7092af89c32dde5b14d4fdf8a09 (patch) | |
tree | 659e99ee562c163d4d26e2060969bcbd13a6311f /net | |
parent | 32f1bc0f3d262125169f9212aac306c638e34b54 (diff) |
DECnet: Use container_of() for embedded struct
Instead of a direct cross-type cast, use conatiner_of() to locate
the embedded structure, even in the face of future struct layout
randomization.
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/decnet/dn_neigh.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/net/decnet/dn_neigh.c b/net/decnet/dn_neigh.c index 482730cd8a56..eeb5fc561f80 100644 --- a/net/decnet/dn_neigh.c +++ b/net/decnet/dn_neigh.c | |||
@@ -110,7 +110,7 @@ struct neigh_table dn_neigh_table = { | |||
110 | static int dn_neigh_construct(struct neighbour *neigh) | 110 | static int dn_neigh_construct(struct neighbour *neigh) |
111 | { | 111 | { |
112 | struct net_device *dev = neigh->dev; | 112 | struct net_device *dev = neigh->dev; |
113 | struct dn_neigh *dn = (struct dn_neigh *)neigh; | 113 | struct dn_neigh *dn = container_of(neigh, struct dn_neigh, n); |
114 | struct dn_dev *dn_db; | 114 | struct dn_dev *dn_db; |
115 | struct neigh_parms *parms; | 115 | struct neigh_parms *parms; |
116 | 116 | ||
@@ -339,7 +339,7 @@ int dn_to_neigh_output(struct net *net, struct sock *sk, struct sk_buff *skb) | |||
339 | struct dst_entry *dst = skb_dst(skb); | 339 | struct dst_entry *dst = skb_dst(skb); |
340 | struct dn_route *rt = (struct dn_route *) dst; | 340 | struct dn_route *rt = (struct dn_route *) dst; |
341 | struct neighbour *neigh = rt->n; | 341 | struct neighbour *neigh = rt->n; |
342 | struct dn_neigh *dn = (struct dn_neigh *)neigh; | 342 | struct dn_neigh *dn = container_of(neigh, struct dn_neigh, n); |
343 | struct dn_dev *dn_db; | 343 | struct dn_dev *dn_db; |
344 | bool use_long; | 344 | bool use_long; |
345 | 345 | ||
@@ -391,7 +391,7 @@ int dn_neigh_router_hello(struct net *net, struct sock *sk, struct sk_buff *skb) | |||
391 | 391 | ||
392 | neigh = __neigh_lookup(&dn_neigh_table, &src, skb->dev, 1); | 392 | neigh = __neigh_lookup(&dn_neigh_table, &src, skb->dev, 1); |
393 | 393 | ||
394 | dn = (struct dn_neigh *)neigh; | 394 | dn = container_of(neigh, struct dn_neigh, n); |
395 | 395 | ||
396 | if (neigh) { | 396 | if (neigh) { |
397 | write_lock(&neigh->lock); | 397 | write_lock(&neigh->lock); |
@@ -451,7 +451,7 @@ int dn_neigh_endnode_hello(struct net *net, struct sock *sk, struct sk_buff *skb | |||
451 | 451 | ||
452 | neigh = __neigh_lookup(&dn_neigh_table, &src, skb->dev, 1); | 452 | neigh = __neigh_lookup(&dn_neigh_table, &src, skb->dev, 1); |
453 | 453 | ||
454 | dn = (struct dn_neigh *)neigh; | 454 | dn = container_of(neigh, struct dn_neigh, n); |
455 | 455 | ||
456 | if (neigh) { | 456 | if (neigh) { |
457 | write_lock(&neigh->lock); | 457 | write_lock(&neigh->lock); |
@@ -510,7 +510,7 @@ static void neigh_elist_cb(struct neighbour *neigh, void *_info) | |||
510 | if (neigh->dev != s->dev) | 510 | if (neigh->dev != s->dev) |
511 | return; | 511 | return; |
512 | 512 | ||
513 | dn = (struct dn_neigh *) neigh; | 513 | dn = container_of(neigh, struct dn_neigh, n); |
514 | if (!(dn->flags & (DN_NDFLAG_R1|DN_NDFLAG_R2))) | 514 | if (!(dn->flags & (DN_NDFLAG_R1|DN_NDFLAG_R2))) |
515 | return; | 515 | return; |
516 | 516 | ||
@@ -549,7 +549,7 @@ int dn_neigh_elist(struct net_device *dev, unsigned char *ptr, int n) | |||
549 | static inline void dn_neigh_format_entry(struct seq_file *seq, | 549 | static inline void dn_neigh_format_entry(struct seq_file *seq, |
550 | struct neighbour *n) | 550 | struct neighbour *n) |
551 | { | 551 | { |
552 | struct dn_neigh *dn = (struct dn_neigh *) n; | 552 | struct dn_neigh *dn = container_of(n, struct dn_neigh, n); |
553 | char buf[DN_ASCBUF_LEN]; | 553 | char buf[DN_ASCBUF_LEN]; |
554 | 554 | ||
555 | read_lock(&n->lock); | 555 | read_lock(&n->lock); |