From 431b9de171033566fdc29a12e7681b3cfab15d55 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Thu, 15 Jul 2004 16:13:11 +0000 Subject: Insist that callers use atw_write_sram to copy even-length buffers to even offsets in the ADM8211 SRAM. From NetBSD (dyoung). --- sys/dev/ic/atw.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'sys') diff --git a/sys/dev/ic/atw.c b/sys/dev/ic/atw.c index 3e2c366df4f..de797105ad6 100644 --- a/sys/dev/ic/atw.c +++ b/sys/dev/ic/atw.c @@ -1,5 +1,5 @@ -/* $OpenBSD: atw.c,v 1.19 2004/07/15 16:11:51 millert Exp $ */ -/* $NetBSD: atw.c,v 1.64 2004/07/15 07:26:17 dyoung Exp $ */ +/* $OpenBSD: atw.c,v 1.20 2004/07/15 16:13:10 millert Exp $ */ +/* $NetBSD: atw.c,v 1.65 2004/07/15 07:31:05 dyoung Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2002, 2003, 2004 The NetBSD Foundation, Inc. @@ -43,7 +43,7 @@ #include #if defined(__NetBSD__) -__KERNEL_RCSID(0, "$NetBSD: atw.c,v 1.64 2004/07/15 07:26:17 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: atw.c,v 1.65 2004/07/15 07:31:05 dyoung Exp $"); #endif #include "bpfilter.h" @@ -2028,15 +2028,9 @@ atw_write_sram(struct atw_softc *sc, u_int ofs, u_int8_t *buf, u_int buflen) memcpy(&sc->sc_sram[ofs], buf, buflen); - if (ofs % 2 != 0) { - ofs--; - buflen++; - } - - if (buflen % 2 != 0) - buflen++; + KASSERT(ofs % 2 == 0 && buflen % 2 == 0); - assert(buflen + ofs <= ATW_SRAM_SIZE); + KASSERT(buflen + ofs <= ATW_SRAM_SIZE); ptr = &sc->sc_sram[ofs]; -- cgit v1.2.3