Date: Fri, 24 Sep 2010 19:15:00 +0000 (UTC) From: Pyun YongHyeon <yongari@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org Subject: svn commit: r213123 - stable/7/sys/dev/ed Message-ID: <201009241915.o8OJF09n036506@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: yongari Date: Fri Sep 24 19:14:59 2010 New Revision: 213123 URL: http://svn.freebsd.org/changeset/base/213123 Log: MFC r211721: Fix a possible unaligned access to savebyte array. PR: kern/122195 Modified: stable/7/sys/dev/ed/if_ed.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/ed/if_ed.c ============================================================================== --- stable/7/sys/dev/ed/if_ed.c Fri Sep 24 19:13:43 2010 (r213122) +++ stable/7/sys/dev/ed/if_ed.c Fri Sep 24 19:14:59 2010 (r213123) @@ -1457,9 +1457,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; @@ -1469,9 +1472,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; @@ -1485,7 +1488,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; } } @@ -1493,7 +1496,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); } /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201009241915.o8OJF09n036506>