diff options
author | yongari <yongari@FreeBSD.org> | 2010-08-27 23:50:13 +0000 |
---|---|---|
committer | yongari <yongari@FreeBSD.org> | 2010-08-27 23:50:13 +0000 |
commit | 3042945d009442792cd49093d9a4e06fabe532cd (patch) | |
tree | 9cc089928c0a6796df540cea60db499c05e7c87f /sys/dev/e1000 | |
parent | 55923119b2028b7ad97b58d58acde068afe9e8b1 (diff) | |
download | FreeBSD-src-3042945d009442792cd49093d9a4e06fabe532cd.zip FreeBSD-src-3042945d009442792cd49093d9a4e06fabe532cd.tar.gz |
Make sure not to access unallocated stats memory.
Reviewed by: jfv
Diffstat (limited to 'sys/dev/e1000')
-rw-r--r-- | sys/dev/e1000/if_igb.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sys/dev/e1000/if_igb.c b/sys/dev/e1000/if_igb.c index 412ea9e..fd8804a 100644 --- a/sys/dev/e1000/if_igb.c +++ b/sys/dev/e1000/if_igb.c @@ -509,6 +509,11 @@ igb_attach(device_t dev) adapter->stats = (struct e1000_hw_stats *)malloc(sizeof \ (struct e1000_hw_stats), M_DEVBUF, M_NOWAIT | M_ZERO); + if (adapter->stats == NULL) { + device_printf(dev, "Can not allocate stats memory\n"); + error = ENOMEM; + goto err_late; + } /* ** Start from a known state, this is @@ -4893,7 +4898,8 @@ igb_vf_init_stats(struct adapter *adapter) struct e1000_vf_stats *stats; stats = (struct e1000_vf_stats *)adapter->stats; - + if (stats == NULL) + return; stats->last_gprc = E1000_READ_REG(hw, E1000_VFGPRC); stats->last_gorc = E1000_READ_REG(hw, E1000_VFGORC); stats->last_gptc = E1000_READ_REG(hw, E1000_VFGPTC); |