Check pointer for NULL before dereferencing it, not after.
PR: 138387, 138388 Submitted by: Patroklos Argyroudis <argp@census-labs.com> MFC after: 1 week
This commit is contained in:
parent
4382b0681e
commit
ef1be3b042
@ -486,12 +486,15 @@ lptopen(struct cdev *dev, int flags, int fmt, struct thread *td)
|
|||||||
{
|
{
|
||||||
int trys, err;
|
int trys, err;
|
||||||
struct lpt_data *sc = dev->si_drv1;
|
struct lpt_data *sc = dev->si_drv1;
|
||||||
device_t lptdev = sc->sc_dev;
|
device_t lptdev;
|
||||||
device_t ppbus = device_get_parent(lptdev);
|
device_t ppbus;
|
||||||
|
|
||||||
if (!sc)
|
if (!sc)
|
||||||
return (ENXIO);
|
return (ENXIO);
|
||||||
|
|
||||||
|
lptdev = sc->sc_dev;
|
||||||
|
ppbus = device_get_parent(lptdev);
|
||||||
|
|
||||||
ppb_lock(ppbus);
|
ppb_lock(ppbus);
|
||||||
if (sc->sc_state) {
|
if (sc->sc_state) {
|
||||||
lprintf(("%s: still open %x\n", device_get_nameunit(lptdev),
|
lprintf(("%s: still open %x\n", device_get_nameunit(lptdev),
|
||||||
|
@ -150,12 +150,14 @@ static int
|
|||||||
pcfclock_open(struct cdev *dev, int flag, int fms, struct thread *td)
|
pcfclock_open(struct cdev *dev, int flag, int fms, struct thread *td)
|
||||||
{
|
{
|
||||||
struct pcfclock_data *sc = dev->si_drv1;
|
struct pcfclock_data *sc = dev->si_drv1;
|
||||||
device_t pcfclockdev = sc->dev;
|
device_t pcfclockdev;
|
||||||
device_t ppbus = device_get_parent(pcfclockdev);
|
device_t ppbus;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
if (!sc)
|
if (!sc)
|
||||||
return (ENXIO);
|
return (ENXIO);
|
||||||
|
pcfclockdev = sc->dev;
|
||||||
|
ppbus = device_get_parent(pcfclockdev);
|
||||||
|
|
||||||
ppb_lock(ppbus);
|
ppb_lock(ppbus);
|
||||||
res = ppb_request_bus(ppbus, pcfclockdev,
|
res = ppb_request_bus(ppbus, pcfclockdev,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user