svn commit: r211721 - head/sys/dev/ed

Pyun YongHyeon yongari at FreeBSD.org
Mon Aug 23 21:40:05 UTC 2010


Author: yongari
Date: Mon Aug 23 21:40:03 2010
New Revision: 211721
URL: http://svn.freebsd.org/changeset/base/211721

Log:
  Fix a possible unaligned access to savebyte array.
  
  PR:	kern/122195

Modified:
  head/sys/dev/ed/if_ed.c

Modified: head/sys/dev/ed/if_ed.c
==============================================================================
--- head/sys/dev/ed/if_ed.c	Mon Aug 23 20:53:24 2010	(r211720)
+++ head/sys/dev/ed/if_ed.c	Mon Aug 23 21:40:03 2010	(r211721)
@@ -1476,9 +1476,12 @@ ed_pio_write_mbufs(struct ed_softc *sc, 
 		}
 	} else {
 		/* NE2000s are a pain */
-		unsigned char *data;
+		uint8_t *data;
 		int len, wantbyte;
-		unsigned char savebyte[2];
+		union {
+			uint16_t w;
+			uint8_t b[2];
+		} saveword;
 
 		wantbyte = 0;
 
@@ -1488,9 +1491,9 @@ ed_pio_write_mbufs(struct ed_softc *sc, 
 				data = mtod(m, caddr_t);
 				/* finish the last word */
 				if (wantbyte) {
-					savebyte[1] = *data;
+					saveword.b[1] = *data;
 					ed_asic_outw(sc, ED_NOVELL_DATA,
-						     *(u_short *)savebyte);
+					    saveword.w);
 					data++;
 					len--;
 					wantbyte = 0;
@@ -1504,7 +1507,7 @@ ed_pio_write_mbufs(struct ed_softc *sc, 
 				}
 				/* save last byte, if necessary */
 				if (len == 1) {
-					savebyte[0] = *data;
+					saveword.b[0] = *data;
 					wantbyte = 1;
 				}
 			}
@@ -1512,7 +1515,7 @@ ed_pio_write_mbufs(struct ed_softc *sc, 
 		}
 		/* spit last byte */
 		if (wantbyte)
-			ed_asic_outw(sc, ED_NOVELL_DATA, *(u_short *)savebyte);
+			ed_asic_outw(sc, ED_NOVELL_DATA, saveword.w);
 	}
 
 	/*


More information about the svn-src-all mailing list