From 776ba1d5eee6b217e3333740170c2339a1aea155 Mon Sep 17 00:00:00 2001 From: Rajkumar Manoharan Date: Tue, 29 Jun 2010 12:08:07 +0530 Subject: [PATCH] compat: Fix panic caused by NULL pointer derefence in rtnl_fill_ifinfo get stats netdev ops is blindy called for older kernels (< 2.6.29) and so assigning a NULL pointer from netdev_attach_ops causes a NULL pointer dereference. By default, netdev alloc provides an internal stats reference. So fill this only if ndo_get_stats is defined. Signed-off-by: Rajkumar Manoharan --- compat/compat-2.6.29.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compat/compat-2.6.29.c b/compat/compat-2.6.29.c index f94aed863aef..2e7e623bede5 100644 --- a/compat/compat-2.6.29.c +++ b/compat/compat-2.6.29.c @@ -35,7 +35,8 @@ void netdev_attach_ops(struct net_device *dev, dev->change_mtu = ops->ndo_change_mtu; dev->set_mac_address = ops->ndo_set_mac_address; dev->tx_timeout = ops->ndo_tx_timeout; - dev->get_stats = ops->ndo_get_stats; + if (ops->ndo_get_stats) + dev->get_stats = ops->ndo_get_stats; dev->vlan_rx_register = ops->ndo_vlan_rx_register; dev->vlan_rx_add_vid = ops->ndo_vlan_rx_add_vid; dev->vlan_rx_kill_vid = ops->ndo_vlan_rx_kill_vid; -- 2.30.2