Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Aug 2010 23:50:14 +0000 (UTC)
From:      Pyun YongHyeon <yongari@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r211906 - head/sys/dev/e1000
Message-ID:  <201008272350.o7RNoEt5011440@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201008272350.o7RNoEt5011440>