From owner-svn-src-head@freebsd.org Sat Sep 26 07:14:00 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E344FA09E6C; Sat, 26 Sep 2015 07:14:00 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D4578688; Sat, 26 Sep 2015 07:14:00 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t8Q7E0YQ011789; Sat, 26 Sep 2015 07:14:00 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t8Q7E0jS011788; Sat, 26 Sep 2015 07:14:00 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201509260714.t8Q7E0jS011788@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Sat, 26 Sep 2015 07:14:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r288255 - head/sys/dev/otus X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Sep 2015 07:14:01 -0000 Author: adrian Date: Sat Sep 26 07:14:00 2015 New Revision: 288255 URL: https://svnweb.freebsd.org/changeset/base/288255 Log: Fix a bug in the TX command handling - log when a too-large payload is sent, and fix a bug I found when doing so. Modified: head/sys/dev/otus/if_otus.c Modified: head/sys/dev/otus/if_otus.c ============================================================================== --- head/sys/dev/otus/if_otus.c Sat Sep 26 07:09:46 2015 (r288254) +++ head/sys/dev/otus/if_otus.c Sat Sep 26 07:14:00 2015 (r288255) @@ -1292,6 +1292,14 @@ otus_cmd(struct otus_softc *sc, uint8_t /* Always bulk-out a multiple of 4 bytes. */ xferlen = (sizeof (*hdr) + ilen + 3) & ~3; + if (xferlen > OTUS_MAX_TXCMDSZ) { + device_printf(sc->sc_dev, "%s: command (0x%02x) size (%d) > %d\n", + __func__, + code, + xferlen, + OTUS_MAX_TXCMDSZ); + return (EIO); + } cmd = otus_get_txcmd(sc); if (cmd == NULL) { @@ -1346,7 +1354,7 @@ otus_write(struct otus_softc *sc, uint32 sc->write_buf[sc->write_idx].reg = htole32(reg); sc->write_buf[sc->write_idx].val = htole32(val); - if (++sc->write_idx > AR_MAX_WRITE_IDX) + if (++sc->write_idx > (AR_MAX_WRITE_IDX-1)) (void)otus_write_barrier(sc); }