netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net/core: fixing dst_neigh_lookup/dst_neigh_lookup_skb caused kernel panic
@ 2013-03-13  4:00 Zhouyi Zhou
  2013-03-13 14:33 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Zhouyi Zhou @ 2013-03-13  4:00 UTC (permalink / raw)
  To: netdev; +Cc: stable, trivial

 when neighbour table is full, dst_neigh_lookup/dst_neigh_lookup_skb
will return -ENOBUFS which
is absolutely non zero, while all the code in kernel which use above
functions  assume failure only
on zero return (I did a grep), which will cause kernel panic. (for
example: https://bugzilla.kernel.org/show_bug.cgi?id=54731)

  This patch corrects above error with smallest changes to kernel source code.
Signed-off-by: Zhouyi Zhou <zhouzhouyi@gmail.com>

diff --git a/include/net/dst.h b/include/net/dst.h
index 853cda1..d594f8b 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -413,13 +413,15 @@ static inline int dst_neigh_output(struct
dst_entry *dst, struct neighbour *n,

 static inline struct neighbour *dst_neigh_lookup(const struct
dst_entry *dst, const void *daddr)
 {
-       return dst->ops->neigh_lookup(dst, NULL, daddr);
+       struct neighbour *n = dst->ops->neigh_lookup(dst, NULL, daddr);
+       return IS_ERR(n) ? NULL : n;
 }

 static inline struct neighbour *dst_neigh_lookup_skb(const struct
dst_entry *dst,
                                                     struct sk_buff *skb)
 {
-       return dst->ops->neigh_lookup(dst, skb, NULL);
+       struct neighbour *n = dst->ops->neigh_lookup(dst, skb, NULL);
+       return IS_ERR(n) ? NULL : n;
 }

 static inline void dst_link_failure(struct sk_buff *skb)

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-03-13 14:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-13  4:00 [PATCH] net/core: fixing dst_neigh_lookup/dst_neigh_lookup_skb caused kernel panic Zhouyi Zhou
2013-03-13 14:33 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).