From: jsg Date: Fri, 25 Apr 2014 09:41:21 +0000 (+0000) Subject: don't access a pointer till after the null check X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=49f5879f474dbc9589f8234822c81529730ab9bf;p=openbsd don't access a pointer till after the null check ok mikeb@ --- diff --git a/sbin/iked/pfkey.c b/sbin/iked/pfkey.c index 09f1626b4ac..69c76a8b7ca 100644 --- a/sbin/iked/pfkey.c +++ b/sbin/iked/pfkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfkey.c,v 1.29 2014/02/21 20:52:38 markus Exp $ */ +/* $OpenBSD: pfkey.c,v 1.30 2014/04/25 09:41:21 jsg Exp $ */ /* * Copyright (c) 2010-2013 Reyk Floeter @@ -1521,7 +1521,7 @@ pfkey_process(struct iked *env, struct pfkey_message *pm) struct sadb_x_policy sa_pol; struct sockaddr *ssrc, *sdst, *smask, *dmask, *speer; struct iovec iov[IOV_CNT]; - int iov_cnt, sd = env->sc_pfkey; + int iov_cnt, sd; u_int8_t *reply; ssize_t rlen; const char *errmsg = NULL; @@ -1532,6 +1532,7 @@ pfkey_process(struct iked *env, struct pfkey_message *pm) if (!env || !data || !len) return; + sd = env->sc_pfkey; hdr = (struct sadb_msg *)data; switch (hdr->sadb_msg_type) { diff --git a/sys/dev/pci/mpii.c b/sys/dev/pci/mpii.c index 09d2c547047..b4cc347df3f 100644 --- a/sys/dev/pci/mpii.c +++ b/sys/dev/pci/mpii.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpii.c,v 1.92 2014/04/10 01:28:32 dlg Exp $ */ +/* $OpenBSD: mpii.c,v 1.93 2014/04/25 09:43:04 jsg Exp $ */ /* * Copyright (c) 2010, 2012 Mike Belopuhov * Copyright (c) 2009 James Giannoules @@ -2297,10 +2297,11 @@ mpii_dmamem_free(struct mpii_softc *sc, struct mpii_dmamem *mdm) int mpii_insert_dev(struct mpii_softc *sc, struct mpii_device *dev) { - int slot = dev->slot; /* initial hint */ + int slot; /* initial hint */ - if (dev == NULL || slot < 0) + if (dev == NULL || dev->slot < 0) return (1); + slot = dev->slot; while (slot < sc->sc_max_devices && sc->sc_devs[slot] != NULL) slot++;