Module Name: src
Committed By: maya
Date: Mon Oct 9 23:24:22 UTC 2017
Modified Files:
src/sys/dev/pci: mpii.c
Log Message:
Reorder to avoid null deref before null test
To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/pci/mpii.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/pci/mpii.c
diff -u src/sys/dev/pci/mpii.c:1.9 src/sys/dev/pci/mpii.c:1.10
--- src/sys/dev/pci/mpii.c:1.9 Sun Jun 25 15:56:32 2017
+++ src/sys/dev/pci/mpii.c Mon Oct 9 23:24:22 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: mpii.c,v 1.9 2017/06/25 15:56:32 christos Exp $ */
+/* $NetBSD: mpii.c,v 1.10 2017/10/09 23:24:22 maya Exp $ */
/* OpenBSD: mpii.c,v 1.51 2012/04/11 13:29:14 naddy Exp */
/*
* Copyright (c) 2010 Mike Belopuhov <[email protected]>
@@ -20,7 +20,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.9 2017/06/25 15:56:32 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.10 2017/10/09 23:24:22 maya Exp $");
#include "bio.h"
@@ -4108,10 +4108,12 @@ mpii_alloc_dev(struct mpii_softc *sc)
static int
mpii_insert_dev(struct mpii_softc *sc, struct mpii_device *dev)
{
- int slot = dev->slot; /* initial hint */
- if (!dev || slot < 0)
+ if (!dev || dev->slot < 0)
return (1);
+
+ int slot = dev->slot; /* initial hint */
+
while (slot < sc->sc_max_devices && sc->sc_devs[slot] != NULL)
slot++;
if (slot >= sc->sc_max_devices)