From christoph.mallon@gmx.de  Sat Feb 23 11:35:08 2013
Return-Path: <christoph.mallon@gmx.de>
Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115])
	by hub.freebsd.org (Postfix) with ESMTP id CD56814A
	for <freebsd-gnats-submit@freebsd.org>; Sat, 23 Feb 2013 11:35:08 +0000 (UTC)
	(envelope-from christoph.mallon@gmx.de)
Received: from mout.gmx.net (mout.gmx.net [212.227.17.21])
	by mx1.freebsd.org (Postfix) with ESMTP id 7A3FB99F
	for <freebsd-gnats-submit@freebsd.org>; Sat, 23 Feb 2013 11:35:08 +0000 (UTC)
Received: from mailout-de.gmx.net ([10.1.76.32]) by mrigmx.server.lan
 (mrigmx001) with ESMTP (Nemesis) id 0M38or-1V1sCa0KIR-00svf9 for
 <FreeBSD-gnats-submit@freebsd.org>; Sat, 23 Feb 2013 12:35:07 +0100
Received: (qmail invoked by alias); 23 Feb 2013 11:35:06 -0000
Received: from p5B132CB8.dip.t-dialin.net (EHLO rotluchs.lokal) [91.19.44.184]
  by mail.gmx.net (mp032) with SMTP; 23 Feb 2013 12:35:06 +0100
Received: from tron by rotluchs.lokal with local (Exim 4.80.1 (FreeBSD))
	(envelope-from <christoph.mallon@gmx.de>)
	id 1U9DNh-000DUz-37
	for FreeBSD-gnats-submit@freebsd.org; Sat, 23 Feb 2013 12:35:05 +0100
Message-Id: <E1U9DNh-000DUz-37@rotluchs.lokal>
Date: Sat, 23 Feb 2013 12:35:05 +0100
From: Christoph Mallon <christoph.mallon@gmx.de>
Reply-To: Christoph Mallon <christoph.mallon@gmx.de>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] mxge: Correct some problem and do some cleanups
X-Send-Pr-Version: 3.114
X-GNATS-Notify: Andrew Gallatin <gallatin@FreeBSD.org>

>Number:         176369
>Category:       kern
>Synopsis:       [mxge] [patch] Correct some problem and do some cleanups
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gallatin
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Sat Feb 23 11:40:00 UTC 2013
>Closed-Date:    Tue Mar 05 19:47:32 UTC 2013
>Last-Modified:  Tue Mar 05 19:47:32 UTC 2013
>Originator:     Christoph Mallon
>Release:        
>Organization:
>Environment:


	
>Description:
This patch series corrects some problems (potential buffer overruns) and performs some cleanups in the mxge driver.
- Remove pointless null pointer tests after malloc(..., M_WAITOK).
- Use strncmp() instead of memcmp().
- Use strlcpy() instead of the error-prone strncpy().
- Remove the unused unused union qualhack.
- Check the MAC address in the EEPROM string more strictly.
- Expand the macro MXGE_NEXT_STRING() at its only user.
- Remove unnecessary buffer limit check.
>How-To-Repeat:
	
>Fix:
Please apply these patches.

--- 0001-mxge-Remove-pointless-null-pointer-tests-after-mallo.patch begins here ---
From e65e89fece12ea9ac5b353875e366a103f71e479 Mon Sep 17 00:00:00 2001
From: Christoph Mallon <christoph.mallon@gmx.de>
Date: Sat, 23 Feb 2013 11:06:56 +0100
Subject: [PATCH 1/7] mxge: Remove pointless null pointer tests after
 malloc(..., M_WAITOK).

Some cases would have bogusly returned 0 as error code anyway.
---
 sys/dev/mxge/if_mxge.c | 16 ----------------
 1 file changed, 16 deletions(-)

diff --git a/sys/dev/mxge/if_mxge.c b/sys/dev/mxge/if_mxge.c
index 245c139..a8c8aa4 100644
--- a/sys/dev/mxge/if_mxge.c
+++ b/sys/dev/mxge/if_mxge.c
@@ -3325,8 +3325,6 @@ mxge_alloc_slice_rings(struct mxge_slice_state *ss, int rx_ring_entries,
 	size_t bytes;
 	int err, i;
 
-	err = ENOMEM;
-
 	/* allocate per-slice receive resources */
 
 	ss->rx_small.mask = ss->rx_big.mask = rx_ring_entries - 1;
@@ -3335,24 +3333,16 @@ mxge_alloc_slice_rings(struct mxge_slice_state *ss, int rx_ring_entries,
 	/* allocate the rx shadow rings */
 	bytes = rx_ring_entries * sizeof (*ss->rx_small.shadow);
 	ss->rx_small.shadow = malloc(bytes, M_DEVBUF, M_ZERO|M_WAITOK);
-	if (ss->rx_small.shadow == NULL)
-		return err;
 
 	bytes = rx_ring_entries * sizeof (*ss->rx_big.shadow);
 	ss->rx_big.shadow = malloc(bytes, M_DEVBUF, M_ZERO|M_WAITOK);
-	if (ss->rx_big.shadow == NULL)
-		return err;
 
 	/* allocate the rx host info rings */
 	bytes = rx_ring_entries * sizeof (*ss->rx_small.info);
 	ss->rx_small.info = malloc(bytes, M_DEVBUF, M_ZERO|M_WAITOK);
-	if (ss->rx_small.info == NULL)
-		return err;
 
 	bytes = rx_ring_entries * sizeof (*ss->rx_big.info);
 	ss->rx_big.info = malloc(bytes, M_DEVBUF, M_ZERO|M_WAITOK);
-	if (ss->rx_big.info == NULL)
-		return err;
 
 	/* allocate the rx busdma resources */
 	err = bus_dma_tag_create(sc->parent_dmat,	/* parent */
@@ -3449,8 +3439,6 @@ mxge_alloc_slice_rings(struct mxge_slice_state *ss, int rx_ring_entries,
 	bytes = 8 + 
 		sizeof (*ss->tx.req_list) * (ss->tx.max_desc + 4);
 	ss->tx.req_bytes = malloc(bytes, M_DEVBUF, M_WAITOK);
-	if (ss->tx.req_bytes == NULL)
-		return err;
 	/* ensure req_list entries are aligned to 8 bytes */
 	ss->tx.req_list = (mcp_kreq_ether_send_t *)
 		((unsigned long)(ss->tx.req_bytes + 7) & ~7UL);
@@ -3459,14 +3447,10 @@ mxge_alloc_slice_rings(struct mxge_slice_state *ss, int rx_ring_entries,
 	bytes = sizeof (*ss->tx.seg_list) * ss->tx.max_desc;
 	ss->tx.seg_list = (bus_dma_segment_t *) 
 		malloc(bytes, M_DEVBUF, M_WAITOK);
-	if (ss->tx.seg_list == NULL)
-		return err;
 
 	/* allocate the tx host info ring */
 	bytes = tx_ring_entries * sizeof (*ss->tx.info);
 	ss->tx.info = malloc(bytes, M_DEVBUF, M_ZERO|M_WAITOK);
-	if (ss->tx.info == NULL)
-		return err;
 	
 	/* allocate the tx busdma resources */
 	err = bus_dma_tag_create(sc->parent_dmat,	/* parent */
-- 
1.8.1.3
--- 0001-mxge-Remove-pointless-null-pointer-tests-after-mallo.patch ends here ---

--- dummy1 begins here ---
dummy file, because GNATS damages every other file
--- dummy1 ends here ---

--- 0002-mxge-Use-strncmp-instead-of-memcmp.patch begins here ---
From 8187c30fc513ce4e9e57692ea9f21495fd92d7cc Mon Sep 17 00:00:00 2001
From: Christoph Mallon <christoph.mallon@gmx.de>
Date: Sat, 23 Feb 2013 11:13:24 +0100
Subject: [PATCH 2/7] mxge: Use strncmp() instead of memcmp().

memcmp() assumes that both buffers are at least as big as the given length.
This might not hold for ptr, but it is guaranteed to be NUL terminated.
---
 sys/dev/mxge/if_mxge.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sys/dev/mxge/if_mxge.c b/sys/dev/mxge/if_mxge.c
index a8c8aa4..1c1f74a 100644
--- a/sys/dev/mxge/if_mxge.c
+++ b/sys/dev/mxge/if_mxge.c
@@ -298,7 +298,7 @@ mxge_parse_strings(mxge_softc_t *sc)
 	found_mac = 0;
 	found_sn2 = 0;
 	while (ptr < limit && *ptr != '\0') {
-		if (memcmp(ptr, "MAC=", 4) == 0) {
+		if (strncmp(ptr, "MAC=", 4) == 0) {
 			ptr += 1;
 			sc->mac_addr_string = ptr;
 			for (i = 0; i < 6; i++) {
@@ -308,15 +308,15 @@ mxge_parse_strings(mxge_softc_t *sc)
 				sc->mac_addr[i] = strtoul(ptr, NULL, 16);
 				found_mac = 1;
 			}
-		} else if (memcmp(ptr, "PC=", 3) == 0) {
+		} else if (strncmp(ptr, "PC=", 3) == 0) {
 			ptr += 3;
 			strncpy(sc->product_code_string, ptr,
 				sizeof (sc->product_code_string) - 1);
-		} else if (!found_sn2 && (memcmp(ptr, "SN=", 3) == 0)) {
+		} else if (!found_sn2 && (strncmp(ptr, "SN=", 3) == 0)) {
 			ptr += 3;
 			strncpy(sc->serial_number_string, ptr,
 				sizeof (sc->serial_number_string) - 1);
-		} else if (memcmp(ptr, "SN2=", 4) == 0) {
+		} else if (strncmp(ptr, "SN2=", 4) == 0) {
 			/* SN2 takes precedence over SN */
 			ptr += 4;
 			found_sn2 = 1;
-- 
1.8.1.3
--- 0002-mxge-Use-strncmp-instead-of-memcmp.patch ends here ---

--- dummy2 begins here ---
dummy file, because GNATS damages every other file
--- dummy2 ends here ---

--- 0003-mxge-Use-strlcpy-instead-of-the-error-prone-strncpy.patch begins here ---
From 88577d758e90542b822f93ea5a6ab53384c67629 Mon Sep 17 00:00:00 2001
From: Christoph Mallon <christoph.mallon@gmx.de>
Date: Sat, 23 Feb 2013 11:17:59 +0100
Subject: [PATCH 3/7] mxge: Use strlcpy() instead of the error-prone strncpy().

In one case, NUL termination was not guaranteed.
---
 sys/dev/mxge/if_mxge.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/sys/dev/mxge/if_mxge.c b/sys/dev/mxge/if_mxge.c
index 1c1f74a..a5c0a4e 100644
--- a/sys/dev/mxge/if_mxge.c
+++ b/sys/dev/mxge/if_mxge.c
@@ -310,18 +310,18 @@ mxge_parse_strings(mxge_softc_t *sc)
 			}
 		} else if (strncmp(ptr, "PC=", 3) == 0) {
 			ptr += 3;
-			strncpy(sc->product_code_string, ptr,
-				sizeof (sc->product_code_string) - 1);
+			strlcpy(sc->product_code_string, ptr,
+			    sizeof(sc->product_code_string));
 		} else if (!found_sn2 && (strncmp(ptr, "SN=", 3) == 0)) {
 			ptr += 3;
-			strncpy(sc->serial_number_string, ptr,
-				sizeof (sc->serial_number_string) - 1);
+			strlcpy(sc->serial_number_string, ptr,
+			    sizeof(sc->serial_number_string));
 		} else if (strncmp(ptr, "SN2=", 4) == 0) {
 			/* SN2 takes precedence over SN */
 			ptr += 4;
 			found_sn2 = 1;
-			strncpy(sc->serial_number_string, ptr,
-				sizeof (sc->serial_number_string) - 1);
+			strlcpy(sc->serial_number_string, ptr,
+			    sizeof(sc->serial_number_string));
 		}
 		MXGE_NEXT_STRING(ptr);
 	}
@@ -667,7 +667,7 @@ mxge_validate_firmware(mxge_softc_t *sc, const mcp_gen_header_t *hdr)
 	}
 
 	/* save firmware version for sysctl */
-	strncpy(sc->fw_version, hdr->version, sizeof (sc->fw_version));
+	strlcpy(sc->fw_version, hdr->version, sizeof(sc->fw_version));
 	if (mxge_verbose)
 		device_printf(sc->dev, "firmware id: %s\n", hdr->version);
 
-- 
1.8.1.3
--- 0003-mxge-Use-strlcpy-instead-of-the-error-prone-strncpy.patch ends here ---

--- dummy3 begins here ---
dummy file, because GNATS damages every other file
--- dummy3 ends here ---

--- 0004-mxge-Remove-the-unused-unused-union-qualhack.patch begins here ---
From 4fa46cd078dfe5dadd975d322322d1c6f4f17bb6 Mon Sep 17 00:00:00 2001
From: Christoph Mallon <christoph.mallon@gmx.de>
Date: Sat, 23 Feb 2013 11:27:22 +0100
Subject: [PATCH 4/7] mxge: Remove the unused unused union qualhack.

---
 sys/dev/mxge/if_mxge.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/sys/dev/mxge/if_mxge.c b/sys/dev/mxge/if_mxge.c
index a5c0a4e..5158c89 100644
--- a/sys/dev/mxge/if_mxge.c
+++ b/sys/dev/mxge/if_mxge.c
@@ -649,12 +649,6 @@ abort:
 	return (mxge_load_firmware(sc, 0));
 }
 
-union qualhack
-{
-        const char *ro_char;
-        char *rw_char;
-};
-
 static int
 mxge_validate_firmware(mxge_softc_t *sc, const mcp_gen_header_t *hdr)
 {
-- 
1.8.1.3
--- 0004-mxge-Remove-the-unused-unused-union-qualhack.patch ends here ---

--- dummy4 begins here ---
dummy file, because GNATS damages every other file
--- dummy4 ends here ---

--- 0005-mxge-Check-the-MAC-address-in-the-EEPROM-string-more.patch begins here ---
From b4eafb7dd4c520849278977801685c68ce1af4fa Mon Sep 17 00:00:00 2001
From: Christoph Mallon <christoph.mallon@gmx.de>
Date: Sat, 23 Feb 2013 12:07:47 +0100
Subject: [PATCH 5/7] mxge: Check the MAC address in the EEPROM string more
 strictly.

---
 sys/dev/mxge/if_mxge.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/sys/dev/mxge/if_mxge.c b/sys/dev/mxge/if_mxge.c
index 5158c89..ca7c7c7 100644
--- a/sys/dev/mxge/if_mxge.c
+++ b/sys/dev/mxge/if_mxge.c
@@ -292,6 +292,7 @@ mxge_parse_strings(mxge_softc_t *sc)
 
 	char *ptr, *limit;
 	int i, found_mac, found_sn2;
+	char *endptr;
 
 	ptr = sc->eeprom_strings;
 	limit = sc->eeprom_strings + MXGE_EEPROM_STRINGS_SIZE;
@@ -299,15 +300,18 @@ mxge_parse_strings(mxge_softc_t *sc)
 	found_sn2 = 0;
 	while (ptr < limit && *ptr != '\0') {
 		if (strncmp(ptr, "MAC=", 4) == 0) {
-			ptr += 1;
-			sc->mac_addr_string = ptr;
-			for (i = 0; i < 6; i++) {
-				ptr += 3;
-				if ((ptr + 2) > limit)
+			ptr += 4;
+			for (i = 0;;) {
+				sc->mac_addr[i] = strtoul(ptr, &endptr, 16);
+				if (endptr - ptr != 2)
+					goto abort;
+				ptr = endptr;
+				if (++i == 6)
+					break;
+				if (*ptr++ != ':')
 					goto abort;
-				sc->mac_addr[i] = strtoul(ptr, NULL, 16);
-				found_mac = 1;
 			}
+			found_mac = 1;
 		} else if (strncmp(ptr, "PC=", 3) == 0) {
 			ptr += 3;
 			strlcpy(sc->product_code_string, ptr,
-- 
1.8.1.3
--- 0005-mxge-Check-the-MAC-address-in-the-EEPROM-string-more.patch ends here ---

--- dummy5 begins here ---
dummy file, because GNATS damages every other file
--- dummy5 ends here ---

--- 0006-mxge-Expand-the-macro-MXGE_NEXT_STRING-at-its-only-u.patch begins here ---
From 058dacee6d3128366b8a45b352019328a6ab5f9c Mon Sep 17 00:00:00 2001
From: Christoph Mallon <christoph.mallon@gmx.de>
Date: Sat, 23 Feb 2013 12:11:38 +0100
Subject: [PATCH 6/7] mxge: Expand the macro MXGE_NEXT_STRING() at its only
 user.

Due to a typo (ptr vs. p) it would not have worked anywhere else anyway.
---
 sys/dev/mxge/if_mxge.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/sys/dev/mxge/if_mxge.c b/sys/dev/mxge/if_mxge.c
index ca7c7c7..0a90f7c 100644
--- a/sys/dev/mxge/if_mxge.c
+++ b/sys/dev/mxge/if_mxge.c
@@ -288,8 +288,6 @@ mxge_dma_free(mxge_dma_t *dma)
 static int
 mxge_parse_strings(mxge_softc_t *sc)
 {
-#define MXGE_NEXT_STRING(p) while(ptr < limit && *ptr++)
-
 	char *ptr, *limit;
 	int i, found_mac, found_sn2;
 	char *endptr;
@@ -327,7 +325,7 @@ mxge_parse_strings(mxge_softc_t *sc)
 			strlcpy(sc->serial_number_string, ptr,
 			    sizeof(sc->serial_number_string));
 		}
-		MXGE_NEXT_STRING(ptr);
+		while (ptr < limit && *ptr++ != '\0') {}
 	}
 
 	if (found_mac)
-- 
1.8.1.3
--- 0006-mxge-Expand-the-macro-MXGE_NEXT_STRING-at-its-only-u.patch ends here ---

--- dummy6 begins here ---
dummy file, because GNATS damages every other file
--- dummy6 ends here ---

--- 0007-mxge-Remove-unnecessary-buffer-limit-check.patch begins here ---
From 358c48a79a8a41b3e6804949d8532ef7ceedd147 Mon Sep 17 00:00:00 2001
From: Christoph Mallon <christoph.mallon@gmx.de>
Date: Sat, 23 Feb 2013 12:13:10 +0100
Subject: [PATCH 7/7] mxge: Remove unnecessary buffer limit check.

The buffer is double-NUL terminated per construction.
---
 sys/dev/mxge/if_mxge.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/sys/dev/mxge/if_mxge.c b/sys/dev/mxge/if_mxge.c
index 0a90f7c..fc07f8c 100644
--- a/sys/dev/mxge/if_mxge.c
+++ b/sys/dev/mxge/if_mxge.c
@@ -288,15 +288,14 @@ mxge_dma_free(mxge_dma_t *dma)
 static int
 mxge_parse_strings(mxge_softc_t *sc)
 {
-	char *ptr, *limit;
+	char *ptr;
 	int i, found_mac, found_sn2;
 	char *endptr;
 
 	ptr = sc->eeprom_strings;
-	limit = sc->eeprom_strings + MXGE_EEPROM_STRINGS_SIZE;
 	found_mac = 0;
 	found_sn2 = 0;
-	while (ptr < limit && *ptr != '\0') {
+	while (*ptr != '\0') {
 		if (strncmp(ptr, "MAC=", 4) == 0) {
 			ptr += 4;
 			for (i = 0;;) {
@@ -325,7 +324,7 @@ mxge_parse_strings(mxge_softc_t *sc)
 			strlcpy(sc->serial_number_string, ptr,
 			    sizeof(sc->serial_number_string));
 		}
-		while (ptr < limit && *ptr++ != '\0') {}
+		while (*ptr++ != '\0') {}
 	}
 
 	if (found_mac)
-- 
1.8.1.3
--- 0007-mxge-Remove-unnecessary-buffer-limit-check.patch ends here ---


>Release-Note:
>Audit-Trail:

From: Andrew Gallatin <gallatin@cs.duke.edu>
To: Christoph Mallon <christoph.mallon@gmx.de>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: kern/176369: [PATCH] mxge: Correct some problem and do some cleanups
Date: Sat, 23 Feb 2013 07:24:20 -0500

 Thanks.  These mostly look good.  I will test & apply
 them when I get to the office on Monday.
 
 Drew
 
Responsible-Changed-From-To: freebsd-bugs->freebsd-net 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sun Feb 24 23:29:46 UTC 2013 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=176369 
Responsible-Changed-From-To: freebsd-net->gallatin 
Responsible-Changed-By: gallatin 
Responsible-Changed-When: Mon Feb 25 13:36:02 UTC 2013 
Responsible-Changed-Why:  
I'll take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=176369 

From: Andrew Gallatin <gallatin@cs.duke.edu>
To: Christoph Mallon <christoph.mallon@gmx.de>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: kern/176369: [PATCH] mxge: Correct some problem and do some cleanups
Date: Mon, 25 Feb 2013 10:47:13 -0500

 On 02/23/13 06:35, Christoph Mallon wrote:
 > Subject: [PATCH 6/7] mxge: Expand the macro MXGE_NEXT_STRING() at its only
 >  user.
 > 
 > Due to a typo (ptr vs. p) it would not have worked anywhere else anyway.
 
 BTW, this actually did work, since the macro was only used in
 one place.  So the ptr vs p typo does not matter in the code,
 but it is stupid & confusing.
 
 Drew
 
 
 PS from CC -E :
 
 static int
 mxge_parse_strings(mxge_softc_t *sc)
 {
 
  char *ptr, *limit;
  int i, found_mac, found_sn2;
  char *endptr;
 
  ptr = sc->eeprom_strings;
  limit = sc->eeprom_strings + 256;
  found_mac = 0;
  found_sn2 = 0;
  while (ptr < limit && *ptr != '\0') {
 <...>
 
  while(ptr < limit && *ptr++);
  }
 
State-Changed-From-To: open->patched 
State-Changed-By: gallatin 
State-Changed-When: Mon Feb 25 16:29:28 UTC 2013 
State-Changed-Why:  
Committed patchset as r247268.  Will MFC after r247159, which touches 
the same code. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=176369 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/176369: commit references a PR
Date: Mon, 25 Feb 2013 16:22:53 +0000 (UTC)

 Author: gallatin
 Date: Mon Feb 25 16:22:40 2013
 New Revision: 247268
 URL: http://svnweb.freebsd.org/changeset/base/247268
 
 Log:
   Several cleanups and fixes to mxge:
   
   - Remove vestigial null pointer tests after malloc(..., M_WAITOK).
   
   - Remove vestigal qualhack union
   
   - Use strlcpy() instead of the error-prone strncpy() when parsing
     EEPROM and copying strings
   
   - Check the MAC address in the EEPROM strings more strictly.
   
   - Expand the macro MXGE_NEXT_STRING() at its only user. Due to a typo,
     the macro was very confusing.
   
   - Remove unnecessary buffer limit check.  The buffer is double-NUL
     terminated per construction.
   
   PR:		kern/176369
   Submitted by:	Christoph Mallon <christoph.mallon gmx.de>
 
 Modified:
   head/sys/dev/mxge/if_mxge.c
 
 Modified: head/sys/dev/mxge/if_mxge.c
 ==============================================================================
 --- head/sys/dev/mxge/if_mxge.c	Mon Feb 25 16:13:21 2013	(r247267)
 +++ head/sys/dev/mxge/if_mxge.c	Mon Feb 25 16:22:40 2013	(r247268)
 @@ -288,42 +288,43 @@ mxge_dma_free(mxge_dma_t *dma)
  static int
  mxge_parse_strings(mxge_softc_t *sc)
  {
 -#define MXGE_NEXT_STRING(p) while(ptr < limit && *ptr++)
 -
 -	char *ptr, *limit;
 +	char *ptr;
  	int i, found_mac, found_sn2;
 +	char *endptr;
  
  	ptr = sc->eeprom_strings;
 -	limit = sc->eeprom_strings + MXGE_EEPROM_STRINGS_SIZE;
  	found_mac = 0;
  	found_sn2 = 0;
 -	while (ptr < limit && *ptr != '\0') {
 -		if (memcmp(ptr, "MAC=", 4) == 0) {
 -			ptr += 1;
 -			sc->mac_addr_string = ptr;
 -			for (i = 0; i < 6; i++) {
 -				ptr += 3;
 -				if ((ptr + 2) > limit)
 +	while (*ptr != '\0') {
 +		if (strncmp(ptr, "MAC=", 4) == 0) {
 +			ptr += 4;
 +			for (i = 0;;) {
 +				sc->mac_addr[i] = strtoul(ptr, &endptr, 16);
 +				if (endptr - ptr != 2)
 +					goto abort;
 +				ptr = endptr;
 +				if (++i == 6)
 +					break;
 +				if (*ptr++ != ':')
  					goto abort;
 -				sc->mac_addr[i] = strtoul(ptr, NULL, 16);
 -				found_mac = 1;
  			}
 -		} else if (memcmp(ptr, "PC=", 3) == 0) {
 +			found_mac = 1;
 +		} else if (strncmp(ptr, "PC=", 3) == 0) {
  			ptr += 3;
 -			strncpy(sc->product_code_string, ptr,
 -				sizeof (sc->product_code_string) - 1);
 -		} else if (!found_sn2 && (memcmp(ptr, "SN=", 3) == 0)) {
 +			strlcpy(sc->product_code_string, ptr,
 +			    sizeof(sc->product_code_string));
 +		} else if (!found_sn2 && (strncmp(ptr, "SN=", 3) == 0)) {
  			ptr += 3;
 -			strncpy(sc->serial_number_string, ptr,
 -				sizeof (sc->serial_number_string) - 1);
 -		} else if (memcmp(ptr, "SN2=", 4) == 0) {
 +			strlcpy(sc->serial_number_string, ptr,
 +			    sizeof(sc->serial_number_string));
 +		} else if (strncmp(ptr, "SN2=", 4) == 0) {
  			/* SN2 takes precedence over SN */
  			ptr += 4;
  			found_sn2 = 1;
 -			strncpy(sc->serial_number_string, ptr,
 -				sizeof (sc->serial_number_string) - 1);
 +			strlcpy(sc->serial_number_string, ptr,
 +			    sizeof(sc->serial_number_string));
  		}
 -		MXGE_NEXT_STRING(ptr);
 +		while (*ptr++ != '\0') {}
  	}
  
  	if (found_mac)
 @@ -649,12 +650,6 @@ abort:
  	return (mxge_load_firmware(sc, 0));
  }
  
 -union qualhack
 -{
 -        const char *ro_char;
 -        char *rw_char;
 -};
 -
  static int
  mxge_validate_firmware(mxge_softc_t *sc, const mcp_gen_header_t *hdr)
  {
 @@ -667,7 +662,7 @@ mxge_validate_firmware(mxge_softc_t *sc,
  	}
  
  	/* save firmware version for sysctl */
 -	strncpy(sc->fw_version, hdr->version, sizeof (sc->fw_version));
 +	strlcpy(sc->fw_version, hdr->version, sizeof(sc->fw_version));
  	if (mxge_verbose)
  		device_printf(sc->dev, "firmware id: %s\n", hdr->version);
  
 @@ -3325,8 +3320,6 @@ mxge_alloc_slice_rings(struct mxge_slice
  	size_t bytes;
  	int err, i;
  
 -	err = ENOMEM;
 -
  	/* allocate per-slice receive resources */
  
  	ss->rx_small.mask = ss->rx_big.mask = rx_ring_entries - 1;
 @@ -3335,24 +3328,16 @@ mxge_alloc_slice_rings(struct mxge_slice
  	/* allocate the rx shadow rings */
  	bytes = rx_ring_entries * sizeof (*ss->rx_small.shadow);
  	ss->rx_small.shadow = malloc(bytes, M_DEVBUF, M_ZERO|M_WAITOK);
 -	if (ss->rx_small.shadow == NULL)
 -		return err;
  
  	bytes = rx_ring_entries * sizeof (*ss->rx_big.shadow);
  	ss->rx_big.shadow = malloc(bytes, M_DEVBUF, M_ZERO|M_WAITOK);
 -	if (ss->rx_big.shadow == NULL)
 -		return err;
  
  	/* allocate the rx host info rings */
  	bytes = rx_ring_entries * sizeof (*ss->rx_small.info);
  	ss->rx_small.info = malloc(bytes, M_DEVBUF, M_ZERO|M_WAITOK);
 -	if (ss->rx_small.info == NULL)
 -		return err;
  
  	bytes = rx_ring_entries * sizeof (*ss->rx_big.info);
  	ss->rx_big.info = malloc(bytes, M_DEVBUF, M_ZERO|M_WAITOK);
 -	if (ss->rx_big.info == NULL)
 -		return err;
  
  	/* allocate the rx busdma resources */
  	err = bus_dma_tag_create(sc->parent_dmat,	/* parent */
 @@ -3449,8 +3434,6 @@ mxge_alloc_slice_rings(struct mxge_slice
  	bytes = 8 + 
  		sizeof (*ss->tx.req_list) * (ss->tx.max_desc + 4);
  	ss->tx.req_bytes = malloc(bytes, M_DEVBUF, M_WAITOK);
 -	if (ss->tx.req_bytes == NULL)
 -		return err;
  	/* ensure req_list entries are aligned to 8 bytes */
  	ss->tx.req_list = (mcp_kreq_ether_send_t *)
  		((unsigned long)(ss->tx.req_bytes + 7) & ~7UL);
 @@ -3459,14 +3442,10 @@ mxge_alloc_slice_rings(struct mxge_slice
  	bytes = sizeof (*ss->tx.seg_list) * ss->tx.max_desc;
  	ss->tx.seg_list = (bus_dma_segment_t *) 
  		malloc(bytes, M_DEVBUF, M_WAITOK);
 -	if (ss->tx.seg_list == NULL)
 -		return err;
  
  	/* allocate the tx host info ring */
  	bytes = tx_ring_entries * sizeof (*ss->tx.info);
  	ss->tx.info = malloc(bytes, M_DEVBUF, M_ZERO|M_WAITOK);
 -	if (ss->tx.info == NULL)
 -		return err;
  	
  	/* allocate the tx busdma resources */
  	err = bus_dma_tag_create(sc->parent_dmat,	/* parent */
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: Christoph Mallon <christoph.mallon@gmx.de>
To: Andrew Gallatin <gallatin@cs.duke.edu>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: kern/176369: [PATCH] mxge: Correct some problem and do some cleanups
Date: Mon, 25 Feb 2013 18:12:44 +0100

 On 25.02.2013 16:47, Andrew Gallatin wrote:
 > On 02/23/13 06:35, Christoph Mallon wrote:
 >> Subject: [PATCH 6/7] mxge: Expand the macro MXGE_NEXT_STRING() at its only
 >>  user.
 >>
 >> Due to a typo (ptr vs. p) it would not have worked anywhere else anyway.
 > 
 > BTW, this actually did work, since the macro was only used in
 > one place.  So the ptr vs p typo does not matter in the code,
 > but it is stupid & confusing.
 
 I did /not/ say, that it did not work.
 I said, that it would not work /anywhere else/, i.e. where the variable is not named ptr, it breaks.
 
 	Christoph

From: Andrew Gallatin <gallatin@cs.duke.edu>
To: Christoph Mallon <christoph.mallon@gmx.de>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: kern/176369: [PATCH] mxge: Correct some problem and do some cleanups
Date: Mon, 25 Feb 2013 12:15:37 -0500

 On 02/25/13 12:12, Christoph Mallon wrote:
 > On 25.02.2013 16:47, Andrew Gallatin wrote:
 >> On 02/23/13 06:35, Christoph Mallon wrote:
 >>> Subject: [PATCH 6/7] mxge: Expand the macro MXGE_NEXT_STRING() at its only
 >>>  user.
 >>>
 >>> Due to a typo (ptr vs. p) it would not have worked anywhere else anyway.
 >>
 >> BTW, this actually did work, since the macro was only used in
 >> one place.  So the ptr vs p typo does not matter in the code,
 >> but it is stupid & confusing.
 > 
 > I did /not/ say, that it did not work.
 > I said, that it would not work /anywhere else/, i.e. where the variable is not named ptr, it breaks.
 > 
 > 	Christoph
 > 
 
 Ah, sorry, I misread.  At any rate, we're both in violent agreement :)
 
 Drew

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/176369: commit references a PR
Date: Tue,  5 Mar 2013 16:37:38 +0000 (UTC)

 Author: gallatin
 Date: Tue Mar  5 16:37:20 2013
 New Revision: 247850
 URL: http://svnweb.freebsd.org/changeset/base/247850
 
 Log:
   MFC r247268:
    Several cleanups and fixes to mxge:
   
    - Remove vestigial null pointer tests after malloc(..., M_WAITOK).
   
    - Remove vestigal qualhack union
   
    - Use strlcpy() instead of the error-prone strncpy() when parsing
      EEPROM and copying strings
   
    - Check the MAC address in the EEPROM strings more strictly.
   
    - Expand the macro MXGE_NEXT_STRING() at its only user. Due to a typo,
      the macro was very confusing.
   
    - Remove unnecessary buffer limit check.  The buffer is double-NUL
      terminated per construction.
   
   PR:             kern/176369
   Submitted by:   Christoph Mallon <christoph.mallon gmx.de>
 
 Modified:
   stable/9/sys/dev/mxge/if_mxge.c
 Directory Properties:
   stable/9/sys/   (props changed)
   stable/9/sys/dev/   (props changed)
 
 Modified: stable/9/sys/dev/mxge/if_mxge.c
 ==============================================================================
 --- stable/9/sys/dev/mxge/if_mxge.c	Tue Mar  5 16:15:34 2013	(r247849)
 +++ stable/9/sys/dev/mxge/if_mxge.c	Tue Mar  5 16:37:20 2013	(r247850)
 @@ -287,42 +287,43 @@ mxge_dma_free(mxge_dma_t *dma)
  static int
  mxge_parse_strings(mxge_softc_t *sc)
  {
 -#define MXGE_NEXT_STRING(p) while(ptr < limit && *ptr++)
 -
 -	char *ptr, *limit;
 +	char *ptr;
  	int i, found_mac, found_sn2;
 +	char *endptr;
  
  	ptr = sc->eeprom_strings;
 -	limit = sc->eeprom_strings + MXGE_EEPROM_STRINGS_SIZE;
  	found_mac = 0;
  	found_sn2 = 0;
 -	while (ptr < limit && *ptr != '\0') {
 -		if (memcmp(ptr, "MAC=", 4) == 0) {
 -			ptr += 1;
 -			sc->mac_addr_string = ptr;
 -			for (i = 0; i < 6; i++) {
 -				ptr += 3;
 -				if ((ptr + 2) > limit)
 +	while (*ptr != '\0') {
 +		if (strncmp(ptr, "MAC=", 4) == 0) {
 +			ptr += 4;
 +			for (i = 0;;) {
 +				sc->mac_addr[i] = strtoul(ptr, &endptr, 16);
 +				if (endptr - ptr != 2)
 +					goto abort;
 +				ptr = endptr;
 +				if (++i == 6)
 +					break;
 +				if (*ptr++ != ':')
  					goto abort;
 -				sc->mac_addr[i] = strtoul(ptr, NULL, 16);
 -				found_mac = 1;
  			}
 -		} else if (memcmp(ptr, "PC=", 3) == 0) {
 +			found_mac = 1;
 +		} else if (strncmp(ptr, "PC=", 3) == 0) {
  			ptr += 3;
 -			strncpy(sc->product_code_string, ptr,
 -				sizeof (sc->product_code_string) - 1);
 -		} else if (!found_sn2 && (memcmp(ptr, "SN=", 3) == 0)) {
 +			strlcpy(sc->product_code_string, ptr,
 +			    sizeof(sc->product_code_string));
 +		} else if (!found_sn2 && (strncmp(ptr, "SN=", 3) == 0)) {
  			ptr += 3;
 -			strncpy(sc->serial_number_string, ptr,
 -				sizeof (sc->serial_number_string) - 1);
 -		} else if (memcmp(ptr, "SN2=", 4) == 0) {
 +			strlcpy(sc->serial_number_string, ptr,
 +			    sizeof(sc->serial_number_string));
 +		} else if (strncmp(ptr, "SN2=", 4) == 0) {
  			/* SN2 takes precedence over SN */
  			ptr += 4;
  			found_sn2 = 1;
 -			strncpy(sc->serial_number_string, ptr,
 -				sizeof (sc->serial_number_string) - 1);
 +			strlcpy(sc->serial_number_string, ptr,
 +			    sizeof(sc->serial_number_string));
  		}
 -		MXGE_NEXT_STRING(ptr);
 +		while (*ptr++ != '\0') {}
  	}
  
  	if (found_mac)
 @@ -648,12 +649,6 @@ abort:
  	return (mxge_load_firmware(sc, 0));
  }
  
 -union qualhack
 -{
 -        const char *ro_char;
 -        char *rw_char;
 -};
 -
  static int
  mxge_validate_firmware(mxge_softc_t *sc, const mcp_gen_header_t *hdr)
  {
 @@ -666,7 +661,7 @@ mxge_validate_firmware(mxge_softc_t *sc,
  	}
  
  	/* save firmware version for sysctl */
 -	strncpy(sc->fw_version, hdr->version, sizeof (sc->fw_version));
 +	strlcpy(sc->fw_version, hdr->version, sizeof(sc->fw_version));
  	if (mxge_verbose)
  		device_printf(sc->dev, "firmware id: %s\n", hdr->version);
  
 @@ -3324,8 +3319,6 @@ mxge_alloc_slice_rings(struct mxge_slice
  	size_t bytes;
  	int err, i;
  
 -	err = ENOMEM;
 -
  	/* allocate per-slice receive resources */
  
  	ss->rx_small.mask = ss->rx_big.mask = rx_ring_entries - 1;
 @@ -3334,24 +3327,16 @@ mxge_alloc_slice_rings(struct mxge_slice
  	/* allocate the rx shadow rings */
  	bytes = rx_ring_entries * sizeof (*ss->rx_small.shadow);
  	ss->rx_small.shadow = malloc(bytes, M_DEVBUF, M_ZERO|M_WAITOK);
 -	if (ss->rx_small.shadow == NULL)
 -		return err;
  
  	bytes = rx_ring_entries * sizeof (*ss->rx_big.shadow);
  	ss->rx_big.shadow = malloc(bytes, M_DEVBUF, M_ZERO|M_WAITOK);
 -	if (ss->rx_big.shadow == NULL)
 -		return err;
  
  	/* allocate the rx host info rings */
  	bytes = rx_ring_entries * sizeof (*ss->rx_small.info);
  	ss->rx_small.info = malloc(bytes, M_DEVBUF, M_ZERO|M_WAITOK);
 -	if (ss->rx_small.info == NULL)
 -		return err;
  
  	bytes = rx_ring_entries * sizeof (*ss->rx_big.info);
  	ss->rx_big.info = malloc(bytes, M_DEVBUF, M_ZERO|M_WAITOK);
 -	if (ss->rx_big.info == NULL)
 -		return err;
  
  	/* allocate the rx busdma resources */
  	err = bus_dma_tag_create(sc->parent_dmat,	/* parent */
 @@ -3448,8 +3433,6 @@ mxge_alloc_slice_rings(struct mxge_slice
  	bytes = 8 + 
  		sizeof (*ss->tx.req_list) * (ss->tx.max_desc + 4);
  	ss->tx.req_bytes = malloc(bytes, M_DEVBUF, M_WAITOK);
 -	if (ss->tx.req_bytes == NULL)
 -		return err;
  	/* ensure req_list entries are aligned to 8 bytes */
  	ss->tx.req_list = (mcp_kreq_ether_send_t *)
  		((unsigned long)(ss->tx.req_bytes + 7) & ~7UL);
 @@ -3458,14 +3441,10 @@ mxge_alloc_slice_rings(struct mxge_slice
  	bytes = sizeof (*ss->tx.seg_list) * ss->tx.max_desc;
  	ss->tx.seg_list = (bus_dma_segment_t *) 
  		malloc(bytes, M_DEVBUF, M_WAITOK);
 -	if (ss->tx.seg_list == NULL)
 -		return err;
  
  	/* allocate the tx host info ring */
  	bytes = tx_ring_entries * sizeof (*ss->tx.info);
  	ss->tx.info = malloc(bytes, M_DEVBUF, M_ZERO|M_WAITOK);
 -	if (ss->tx.info == NULL)
 -		return err;
  	
  	/* allocate the tx busdma resources */
  	err = bus_dma_tag_create(sc->parent_dmat,	/* parent */
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/176369: commit references a PR
Date: Tue,  5 Mar 2013 19:20:42 +0000 (UTC)

 Author: gallatin
 Date: Tue Mar  5 19:20:34 2013
 New Revision: 247853
 URL: http://svnweb.freebsd.org/changeset/base/247853
 
 Log:
   MFC r247268:
    Several cleanups and fixes to mxge:
   
    - Remove vestigial null pointer tests after malloc(..., M_WAITOK).
   
    - Remove vestigal qualhack union
   
    - Use strlcpy() instead of the error-prone strncpy() when parsing
      EEPROM and copying strings
   
    - Check the MAC address in the EEPROM strings more strictly.
   
    - Expand the macro MXGE_NEXT_STRING() at its only user. Due to a typo,
      the macro was very confusing.
   
    - Remove unnecessary buffer limit check.  The buffer is double-NUL
      terminated per construction.
   
   PR:             kern/176369
   Submitted by:   Christoph Mallon <christoph.mallon gmx.de>
 
 Modified:
   stable/8/sys/dev/mxge/if_mxge.c
 Directory Properties:
   stable/8/sys/   (props changed)
   stable/8/sys/dev/   (props changed)
   stable/8/sys/dev/mxge/   (props changed)
 
 Modified: stable/8/sys/dev/mxge/if_mxge.c
 ==============================================================================
 --- stable/8/sys/dev/mxge/if_mxge.c	Tue Mar  5 18:54:41 2013	(r247852)
 +++ stable/8/sys/dev/mxge/if_mxge.c	Tue Mar  5 19:20:34 2013	(r247853)
 @@ -286,42 +286,43 @@ mxge_dma_free(mxge_dma_t *dma)
  static int
  mxge_parse_strings(mxge_softc_t *sc)
  {
 -#define MXGE_NEXT_STRING(p) while(ptr < limit && *ptr++)
 -
 -	char *ptr, *limit;
 +	char *ptr;
  	int i, found_mac, found_sn2;
 +	char *endptr;
  
  	ptr = sc->eeprom_strings;
 -	limit = sc->eeprom_strings + MXGE_EEPROM_STRINGS_SIZE;
  	found_mac = 0;
  	found_sn2 = 0;
 -	while (ptr < limit && *ptr != '\0') {
 -		if (memcmp(ptr, "MAC=", 4) == 0) {
 -			ptr += 1;
 -			sc->mac_addr_string = ptr;
 -			for (i = 0; i < 6; i++) {
 -				ptr += 3;
 -				if ((ptr + 2) > limit)
 +	while (*ptr != '\0') {
 +		if (strncmp(ptr, "MAC=", 4) == 0) {
 +			ptr += 4;
 +			for (i = 0;;) {
 +				sc->mac_addr[i] = strtoul(ptr, &endptr, 16);
 +				if (endptr - ptr != 2)
 +					goto abort;
 +				ptr = endptr;
 +				if (++i == 6)
 +					break;
 +				if (*ptr++ != ':')
  					goto abort;
 -				sc->mac_addr[i] = strtoul(ptr, NULL, 16);
 -				found_mac = 1;
  			}
 -		} else if (memcmp(ptr, "PC=", 3) == 0) {
 +			found_mac = 1;
 +		} else if (strncmp(ptr, "PC=", 3) == 0) {
  			ptr += 3;
 -			strncpy(sc->product_code_string, ptr,
 -				sizeof (sc->product_code_string) - 1);
 -		} else if (!found_sn2 && (memcmp(ptr, "SN=", 3) == 0)) {
 +			strlcpy(sc->product_code_string, ptr,
 +			    sizeof(sc->product_code_string));
 +		} else if (!found_sn2 && (strncmp(ptr, "SN=", 3) == 0)) {
  			ptr += 3;
 -			strncpy(sc->serial_number_string, ptr,
 -				sizeof (sc->serial_number_string) - 1);
 -		} else if (memcmp(ptr, "SN2=", 4) == 0) {
 +			strlcpy(sc->serial_number_string, ptr,
 +			    sizeof(sc->serial_number_string));
 +		} else if (strncmp(ptr, "SN2=", 4) == 0) {
  			/* SN2 takes precedence over SN */
  			ptr += 4;
  			found_sn2 = 1;
 -			strncpy(sc->serial_number_string, ptr,
 -				sizeof (sc->serial_number_string) - 1);
 +			strlcpy(sc->serial_number_string, ptr,
 +			    sizeof(sc->serial_number_string));
  		}
 -		MXGE_NEXT_STRING(ptr);
 +		while (*ptr++ != '\0') {}
  	}
  
  	if (found_mac)
 @@ -647,12 +648,6 @@ abort:
  	return (mxge_load_firmware(sc, 0));
  }
  
 -union qualhack
 -{
 -        const char *ro_char;
 -        char *rw_char;
 -};
 -
  static int
  mxge_validate_firmware(mxge_softc_t *sc, const mcp_gen_header_t *hdr)
  {
 @@ -665,7 +660,7 @@ mxge_validate_firmware(mxge_softc_t *sc,
  	}
  
  	/* save firmware version for sysctl */
 -	strncpy(sc->fw_version, hdr->version, sizeof (sc->fw_version));
 +	strlcpy(sc->fw_version, hdr->version, sizeof(sc->fw_version));
  	if (mxge_verbose)
  		device_printf(sc->dev, "firmware id: %s\n", hdr->version);
  
 @@ -3212,8 +3207,6 @@ mxge_alloc_slice_rings(struct mxge_slice
  	size_t bytes;
  	int err, i;
  
 -	err = ENOMEM;
 -
  	/* allocate per-slice receive resources */
  
  	ss->rx_small.mask = ss->rx_big.mask = rx_ring_entries - 1;
 @@ -3222,24 +3215,16 @@ mxge_alloc_slice_rings(struct mxge_slice
  	/* allocate the rx shadow rings */
  	bytes = rx_ring_entries * sizeof (*ss->rx_small.shadow);
  	ss->rx_small.shadow = malloc(bytes, M_DEVBUF, M_ZERO|M_WAITOK);
 -	if (ss->rx_small.shadow == NULL)
 -		return err;
  
  	bytes = rx_ring_entries * sizeof (*ss->rx_big.shadow);
  	ss->rx_big.shadow = malloc(bytes, M_DEVBUF, M_ZERO|M_WAITOK);
 -	if (ss->rx_big.shadow == NULL)
 -		return err;
  
  	/* allocate the rx host info rings */
  	bytes = rx_ring_entries * sizeof (*ss->rx_small.info);
  	ss->rx_small.info = malloc(bytes, M_DEVBUF, M_ZERO|M_WAITOK);
 -	if (ss->rx_small.info == NULL)
 -		return err;
  
  	bytes = rx_ring_entries * sizeof (*ss->rx_big.info);
  	ss->rx_big.info = malloc(bytes, M_DEVBUF, M_ZERO|M_WAITOK);
 -	if (ss->rx_big.info == NULL)
 -		return err;
  
  	/* allocate the rx busdma resources */
  	err = bus_dma_tag_create(sc->parent_dmat,	/* parent */
 @@ -3336,8 +3321,6 @@ mxge_alloc_slice_rings(struct mxge_slice
  	bytes = 8 + 
  		sizeof (*ss->tx.req_list) * (ss->tx.max_desc + 4);
  	ss->tx.req_bytes = malloc(bytes, M_DEVBUF, M_WAITOK);
 -	if (ss->tx.req_bytes == NULL)
 -		return err;
  	/* ensure req_list entries are aligned to 8 bytes */
  	ss->tx.req_list = (mcp_kreq_ether_send_t *)
  		((unsigned long)(ss->tx.req_bytes + 7) & ~7UL);
 @@ -3346,14 +3329,10 @@ mxge_alloc_slice_rings(struct mxge_slice
  	bytes = sizeof (*ss->tx.seg_list) * ss->tx.max_desc;
  	ss->tx.seg_list = (bus_dma_segment_t *) 
  		malloc(bytes, M_DEVBUF, M_WAITOK);
 -	if (ss->tx.seg_list == NULL)
 -		return err;
  
  	/* allocate the tx host info ring */
  	bytes = tx_ring_entries * sizeof (*ss->tx.info);
  	ss->tx.info = malloc(bytes, M_DEVBUF, M_ZERO|M_WAITOK);
 -	if (ss->tx.info == NULL)
 -		return err;
  	
  	/* allocate the tx busdma resources */
  	err = bus_dma_tag_create(sc->parent_dmat,	/* parent */
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: gallatin 
State-Changed-When: Tue Mar 5 19:47:31 UTC 2013 
State-Changed-Why:  
Committed & MFC'ed back to stable-9 and stable-9  Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=176369 
>Unformatted:
