From owner-cvs-src@FreeBSD.ORG  Fri Oct 12 19:47:43 2007
Return-Path: <owner-cvs-src@FreeBSD.ORG>
Delivered-To: cvs-src@FreeBSD.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 2614116A417;
	Fri, 12 Oct 2007 19:47:43 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from repoman.freebsd.org (repoman.freebsd.org
	[IPv6:2001:4f8:fff6::29])
	by mx1.freebsd.org (Postfix) with ESMTP id 1D50313C459;
	Fri, 12 Oct 2007 19:47:43 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from repoman.freebsd.org (localhost [127.0.0.1])
	by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l9CJlgsS088082;
	Fri, 12 Oct 2007 19:47:42 GMT (envelope-from jhb@repoman.freebsd.org)
Received: (from jhb@localhost)
	by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l9CJlgCG088081;
	Fri, 12 Oct 2007 19:47:42 GMT (envelope-from jhb)
Message-Id: <200710121947.l9CJlgCG088081@repoman.freebsd.org>
From: John Baldwin <jhb@FreeBSD.org>
Date: Fri, 12 Oct 2007 19:47:42 +0000 (UTC)
To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org
X-FreeBSD-CVS-Branch: HEAD
Cc: 
Subject: cvs commit: src/sys/dev/usb ukbd.c
X-BeenThere: cvs-src@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: CVS commit messages for the src tree <cvs-src.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/cvs-src>,
	<mailto:cvs-src-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/cvs-src>
List-Post: <mailto:cvs-src@freebsd.org>
List-Help: <mailto:cvs-src-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/cvs-src>,
	<mailto:cvs-src-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Fri, 12 Oct 2007 19:47:43 -0000

jhb         2007-10-12 19:47:42 UTC

  FreeBSD src repository

  Modified files:
    sys/dev/usb          ukbd.c 
  Log:
  The ukbd driver has some questionable "magic" to for a default keyboard
  which is ukbd0.  Specifically, the keyboard driver structures for ukbd0
  are not allocated/freed but are statically allocated via a persistent
  global variable.  There is some additional magic for the ukbd0 such that
  if the keyboard is marked as probed in this global variable, then we
  don't check to see if the device_t we are probing has an interface.
  
  This causes a problem if an attach of ukbd0 fails without fulling clearing
  the state in the global variable.  Specifically, if the keyboard fails to
  initialize in init_keyboard() or kbd_register(), then the keyboard will
  still be marked as probed.  The USB layer will then try to offer the
  "generic" version of the USB keyboard device (as opposed to the
  per-interface sub-devices) and the ukbd(4) driver will see that the
  keyboard is marked probe and will skip the "is this a per-interface device"
  check.  Later in ukbd_attach() it panics because it tries to dereference
  the interface pointer which is NULL.
  
  The fix is to clear the flags in the persistent keyboard data for ukbd0
  when init_keyboard() or kbd_register() fail.
  
  MFC after:      1 week
  Reviewed by:    imp
  
  Revision  Changes    Path
  1.73      +8 -2      src/sys/dev/usb/ukbd.c