From owner-svn-src-head@freebsd.org Thu Mar 1 00:59:00 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E4173F32731; Thu, 1 Mar 2018 00:58:59 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8A1A76E998; Thu, 1 Mar 2018 00:58:59 +0000 (UTC) (envelope-from cem@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7B97021162; Thu, 1 Mar 2018 00:58:59 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w210wx03084822; Thu, 1 Mar 2018 00:58:59 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w210wxaO084821; Thu, 1 Mar 2018 00:58:59 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201803010058.w210wxaO084821@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Thu, 1 Mar 2018 00:58:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r330136 - head/sys/dev/atkbdc X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: head/sys/dev/atkbdc X-SVN-Commit-Revision: 330136 X-SVN-Commit-Repository: base 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.25 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: Thu, 01 Mar 2018 00:59:00 -0000 Author: cem Date: Thu Mar 1 00:58:59 2018 New Revision: 330136 URL: https://svnweb.freebsd.org/changeset/base/330136 Log: psm(4): Always initialize used values in debug print 'status' array passed to get_mouse_status() is usually uninitialized by callers. Fully populating it with values in get_mouse_status() can fail due to read_aux_data(). Additionally, nothing in API constrains 'len' to be >= 3. In practice, every caller passes three, so perhaps that argument should just be removed. Refactoring is a larger change, though. Remove use of potentially uninitialized values by: 1. Only printing 3 debug statuses if the passed array was at least 'len' >= 3; 2. Populating 'status' array up to first three elements, if read_aux_data() failed. No functional change intended. Reported by: Coverity Sponsored by: Dell EMC Isilon Modified: head/sys/dev/atkbdc/psm.c Modified: head/sys/dev/atkbdc/psm.c ============================================================================== --- head/sys/dev/atkbdc/psm.c Thu Mar 1 00:29:52 2018 (r330135) +++ head/sys/dev/atkbdc/psm.c Thu Mar 1 00:58:59 2018 (r330136) @@ -785,9 +785,12 @@ get_mouse_status(KBDC kbdc, int *status, int flag, int if (status[i] < 0) break; } - - VLOG(1, (LOG_DEBUG, "psm: %s %02x %02x %02x\n", - (flag == 1) ? "data" : "status", status[0], status[1], status[2])); + if (len >= 3) { + for (; i < 3; ++i) + status[i] = 0; + VLOG(1, (LOG_DEBUG, "psm: %s %02x %02x %02x\n", + (flag == 1) ? "data" : "status", status[0], status[1], status[2])); + } return (i); }