From owner-svn-src-all@FreeBSD.ORG Thu Oct 22 06:51:30 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0DB91106566B; Thu, 22 Oct 2009 06:51:30 +0000 (UTC) (envelope-from brueffer@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F0FA38FC0A; Thu, 22 Oct 2009 06:51:29 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9M6pTsW021600; Thu, 22 Oct 2009 06:51:29 GMT (envelope-from brueffer@svn.freebsd.org) Received: (from brueffer@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9M6pTR9021597; Thu, 22 Oct 2009 06:51:29 GMT (envelope-from brueffer@svn.freebsd.org) Message-Id: <200910220651.n9M6pTR9021597@svn.freebsd.org> From: Christian Brueffer Date: Thu, 22 Oct 2009 06:51:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198358 - head/sys/dev/ppbus X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Oct 2009 06:51:30 -0000 Author: brueffer Date: Thu Oct 22 06:51:29 2009 New Revision: 198358 URL: http://svn.freebsd.org/changeset/base/198358 Log: Check pointer for NULL before dereferencing it, not after. PR: 138387, 138388 Submitted by: Patroklos Argyroudis MFC after: 1 week Modified: head/sys/dev/ppbus/lpt.c head/sys/dev/ppbus/pcfclock.c Modified: head/sys/dev/ppbus/lpt.c ============================================================================== --- head/sys/dev/ppbus/lpt.c Thu Oct 22 06:17:04 2009 (r198357) +++ head/sys/dev/ppbus/lpt.c Thu Oct 22 06:51:29 2009 (r198358) @@ -486,12 +486,15 @@ lptopen(struct cdev *dev, int flags, int { int trys, err; struct lpt_data *sc = dev->si_drv1; - device_t lptdev = sc->sc_dev; - device_t ppbus = device_get_parent(lptdev); + device_t lptdev; + device_t ppbus; if (!sc) return (ENXIO); + lptdev = sc->sc_dev; + ppbus = device_get_parent(lptdev); + ppb_lock(ppbus); if (sc->sc_state) { lprintf(("%s: still open %x\n", device_get_nameunit(lptdev), Modified: head/sys/dev/ppbus/pcfclock.c ============================================================================== --- head/sys/dev/ppbus/pcfclock.c Thu Oct 22 06:17:04 2009 (r198357) +++ head/sys/dev/ppbus/pcfclock.c Thu Oct 22 06:51:29 2009 (r198358) @@ -150,12 +150,14 @@ static int pcfclock_open(struct cdev *dev, int flag, int fms, struct thread *td) { struct pcfclock_data *sc = dev->si_drv1; - device_t pcfclockdev = sc->dev; - device_t ppbus = device_get_parent(pcfclockdev); + device_t pcfclockdev; + device_t ppbus; int res; if (!sc) return (ENXIO); + pcfclockdev = sc->dev; + ppbus = device_get_parent(pcfclockdev); ppb_lock(ppbus); res = ppb_request_bus(ppbus, pcfclockdev,