diff options
author | brueffer <brueffer@FreeBSD.org> | 2009-10-22 06:51:29 +0000 |
---|---|---|
committer | brueffer <brueffer@FreeBSD.org> | 2009-10-22 06:51:29 +0000 |
commit | 0567fca14237a5e9677251587101c8729486038f (patch) | |
tree | 06591a3e67ce88987a42af8796cde64f6ccc600c /sys/dev/ppbus/lpt.c | |
parent | 245a0bbb51844df0e40b284c191c7ba500ad62ae (diff) | |
download | FreeBSD-src-0567fca14237a5e9677251587101c8729486038f.zip FreeBSD-src-0567fca14237a5e9677251587101c8729486038f.tar.gz |
Check pointer for NULL before dereferencing it, not after.
PR: 138387, 138388
Submitted by: Patroklos Argyroudis <argp@census-labs.com>
MFC after: 1 week
Diffstat (limited to 'sys/dev/ppbus/lpt.c')
-rw-r--r-- | sys/dev/ppbus/lpt.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/sys/dev/ppbus/lpt.c b/sys/dev/ppbus/lpt.c index 56b4378..18d46ae 100644 --- a/sys/dev/ppbus/lpt.c +++ b/sys/dev/ppbus/lpt.c @@ -486,12 +486,15 @@ lptopen(struct cdev *dev, int flags, int fmt, struct thread *td) { 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), |