From owner-svn-src-head@freebsd.org Wed Apr 12 07:21:56 2017 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 8C8FAD3A50A; Wed, 12 Apr 2017 07:21:56 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 420A5B02; Wed, 12 Apr 2017 07:21:56 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3C7Lt7C098197; Wed, 12 Apr 2017 07:21:55 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3C7LtcR098194; Wed, 12 Apr 2017 07:21:55 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201704120721.v3C7LtcR098194@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Wed, 12 Apr 2017 07:21:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r316723 - in head/sys/dev/rtwn: rtl8188e rtl8192c rtl8812a 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.23 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: Wed, 12 Apr 2017 07:21:56 -0000 Author: avos Date: Wed Apr 12 07:21:54 2017 New Revision: 316723 URL: https://svnweb.freebsd.org/changeset/base/316723 Log: rtwn: remove out-of-bounds access + fix debug output. Omit unused rates while initializing / dumping Tx power values. They were not accessed anywhere (except for debugging), so this is (mostly) no-op. Tested with * RTL8188EU, STA mode. * RTL8812AU, STA mode. Found by: PVS-Studio Modified: head/sys/dev/rtwn/rtl8188e/r88e_chan.c head/sys/dev/rtwn/rtl8192c/r92c_chan.c head/sys/dev/rtwn/rtl8812a/r12a_chan.c Modified: head/sys/dev/rtwn/rtl8188e/r88e_chan.c ============================================================================== --- head/sys/dev/rtwn/rtl8188e/r88e_chan.c Wed Apr 12 06:24:35 2017 (r316722) +++ head/sys/dev/rtwn/rtl8188e/r88e_chan.c Wed Apr 12 07:21:54 2017 (r316723) @@ -110,7 +110,7 @@ r88e_get_txpower(struct rtwn_softc *sc, for (ridx = RTWN_RIDX_CCK1; ridx <= RTWN_RIDX_CCK11; ridx++) power[ridx] = base->pwr[0][ridx]; } - for (ridx = RTWN_RIDX_OFDM6; ridx < RTWN_RIDX_COUNT; ridx++) { + for (ridx = RTWN_RIDX_OFDM6; ridx <= max_mcs; ridx++) { if (rs->regulatory == 3) power[ridx] = base->pwr[0][ridx]; else if (rs->regulatory == 1) { Modified: head/sys/dev/rtwn/rtl8192c/r92c_chan.c ============================================================================== --- head/sys/dev/rtwn/rtl8192c/r92c_chan.c Wed Apr 12 06:24:35 2017 (r316722) +++ head/sys/dev/rtwn/rtl8192c/r92c_chan.c Wed Apr 12 07:21:54 2017 (r316723) @@ -229,13 +229,13 @@ r92c_set_txpower(struct rtwn_softc *sc, rtwn_r92c_get_txpower(sc, i, c, power); #ifdef RTWN_DEBUG if (sc->sc_debug & RTWN_DEBUG_TXPWR) { - int ridx; + int max_mcs, ridx; + + max_mcs = RTWN_RIDX_MCS(sc->ntxchains * 8 - 1); /* Dump per-rate Tx power values. */ printf("Tx power for chain %d:\n", i); - for (ridx = RTWN_RIDX_CCK1; - ridx < RTWN_RIDX_COUNT; - ridx++) + for (ridx = RTWN_RIDX_CCK1; ridx <= max_mcs; ridx++) printf("Rate %d = %u\n", ridx, power[ridx]); } #endif Modified: head/sys/dev/rtwn/rtl8812a/r12a_chan.c ============================================================================== --- head/sys/dev/rtwn/rtl8812a/r12a_chan.c Wed Apr 12 06:24:35 2017 (r316722) +++ head/sys/dev/rtwn/rtl8812a/r12a_chan.c Wed Apr 12 07:21:54 2017 (r316723) @@ -247,7 +247,7 @@ r12a_get_txpower(struct rtwn_softc *sc, if (sc->sc_debug & RTWN_DEBUG_TXPWR) { /* Dump per-rate Tx power values. */ printf("Tx power for chain %d:\n", chain); - for (ridx = RTWN_RIDX_CCK1; ridx < RTWN_RIDX_COUNT; ridx++) + for (ridx = RTWN_RIDX_CCK1; ridx <= max_mcs; ridx++) printf("Rate %d = %u\n", ridx, power[ridx]); } #endif