]> git.openfabrics.org - ~emulex/for-vlad/old/compat.git/commitdiff
compat: Fix panic caused by NULL pointer derefence in rtnl_fill_ifinfo
authorRajkumar Manoharan <rmanoharan@atheros.com>
Tue, 29 Jun 2010 06:38:07 +0000 (12:08 +0530)
committerLuis R. Rodriguez <lrodriguez@atheros.com>
Tue, 29 Jun 2010 15:18:07 +0000 (08:18 -0700)
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 <rmanoharan@atheros.com>
compat/compat-2.6.29.c

index f94aed863aefaf74dbda9ccafa8e313115079cb5..2e7e623bede5ac0f5992ffce45d32dff5583b9d5 100644 (file)
@@ -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;