dst: catch uninitialized metrics

Catch cases where dst_metric_set() and other functions are called
but _metrics is NULL.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Stephen Hemminger 2011-05-24 13:50:52 -04:00 committed by David S. Miller
parent 5d8bee676f
commit 1f37070d3f
1 changed files with 2 additions and 0 deletions

View File

@ -111,6 +111,8 @@ static inline u32 *dst_metrics_write_ptr(struct dst_entry *dst)
{ {
unsigned long p = dst->_metrics; unsigned long p = dst->_metrics;
BUG_ON(!p);
if (p & DST_METRICS_READ_ONLY) if (p & DST_METRICS_READ_ONLY)
return dst->ops->cow_metrics(dst, p); return dst->ops->cow_metrics(dst, p);
return __DST_METRICS_PTR(p); return __DST_METRICS_PTR(p);