Skip to content

Commit

Permalink
xfrm: avoid possible oopse in xfrm_alloc_dst
Browse files Browse the repository at this point in the history
Commit 80c802f (xfrm: cache bundles instead of policies for
outgoing flows) introduced possible oopse when dst_alloc returns NULL.

Signed-off-by: Hiroaki SHIMODA <shimoda.hiroaki@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Hiroaki SHIMODA authored and David S. Miller committed Feb 11, 2011
1 parent 520732a commit 0b15093
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions net/xfrm/xfrm_policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1340,10 +1340,13 @@ static inline struct xfrm_dst *xfrm_alloc_dst(struct net *net, int family)
default:
BUG();
}
xdst = dst_alloc(dst_ops) ?: ERR_PTR(-ENOBUFS);
xdst = dst_alloc(dst_ops);
xfrm_policy_put_afinfo(afinfo);

xdst->flo.ops = &xfrm_bundle_fc_ops;
if (likely(xdst))
xdst->flo.ops = &xfrm_bundle_fc_ops;
else
xdst = ERR_PTR(-ENOBUFS);

return xdst;
}
Expand Down

0 comments on commit 0b15093

Please sign in to comment.