Module Name:    src
Committed By:   skrll
Date:           Wed Mar  5 08:45:13 UTC 2014

Modified Files:
        src/sys/dev/scsipi: atapiconf.c

Log Message:
Don't probe beyond chan_ntargets in atapi_probe_bus in the "all" case.

PR/48626: ahci_atapi_probe_device panic with kmemguard


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/sys/dev/scsipi/atapiconf.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/scsipi/atapiconf.c
diff -u src/sys/dev/scsipi/atapiconf.c:1.86 src/sys/dev/scsipi/atapiconf.c:1.87
--- src/sys/dev/scsipi/atapiconf.c:1.86	Sun Jun 24 07:48:01 2012
+++ src/sys/dev/scsipi/atapiconf.c	Wed Mar  5 08:45:13 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: atapiconf.c,v 1.86 2012/06/24 07:48:01 riastradh Exp $	*/
+/*	$NetBSD: atapiconf.c,v 1.87 2014/03/05 08:45:13 skrll Exp $	*/
 
 /*
  * Copyright (c) 1996, 2001 Manuel Bouyer.  All rights reserved.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: atapiconf.c,v 1.86 2012/06/24 07:48:01 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: atapiconf.c,v 1.87 2014/03/05 08:45:13 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -231,8 +231,10 @@ atapi_probe_bus(struct atapibus_softc *s
 	int error;
 	struct atapi_adapter *atapi_adapter;
 
+	KASSERT(chan->chan_ntargets >= 1);
+
 	if (target == -1) {
-		maxtarget = 1;
+		maxtarget = chan->chan_ntargets - 1;
 		mintarget = 0;
 	} else {
 		if (target < 0 || target >= chan->chan_ntargets)

Reply via email to