svn commit: r211906 - head/sys/dev/e1000

Pyun YongHyeon yongari at FreeBSD.org
Fri Aug 27 23:50:14 UTC 2010


Author: yongari
Date: Fri Aug 27 23:50:13 2010
New Revision: 211906
URL: http://svn.freebsd.org/changeset/base/211906

Log:
  Make sure not to access unallocated stats memory.
  
  Reviewed by:	jfv

Modified:
  head/sys/dev/e1000/if_igb.c

Modified: head/sys/dev/e1000/if_igb.c
==============================================================================
--- head/sys/dev/e1000/if_igb.c	Fri Aug 27 23:24:08 2010	(r211905)
+++ head/sys/dev/e1000/if_igb.c	Fri Aug 27 23:50:13 2010	(r211906)
@@ -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 *adapte
 	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);


More information about the svn-src-all mailing list