Module Name:    src
Committed By:   msaitoh
Date:           Mon Feb 19 14:54:04 UTC 2024

Modified Files:
        src/sys/dev/ic: ciss.c

Log Message:
ciss(4): Fix panic when the number of logical drive is zero.

 Currently, this drives requires at least one logical drive.
If there is no any logical volume, don't attach the driver.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/dev/ic/ciss.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/ic/ciss.c
diff -u src/sys/dev/ic/ciss.c:1.55 src/sys/dev/ic/ciss.c:1.56
--- src/sys/dev/ic/ciss.c:1.55	Thu Aug 17 14:19:50 2023
+++ src/sys/dev/ic/ciss.c	Mon Feb 19 14:54:04 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ciss.c,v 1.55 2023/08/17 14:19:50 andvar Exp $	*/
+/*	$NetBSD: ciss.c,v 1.56 2024/02/19 14:54:04 msaitoh Exp $	*/
 /*	$OpenBSD: ciss.c,v 1.68 2013/05/30 16:15:02 deraadt Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ciss.c,v 1.55 2023/08/17 14:19:50 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ciss.c,v 1.56 2024/02/19 14:54:04 msaitoh Exp $");
 
 #include "bio.h"
 
@@ -427,6 +427,14 @@ ciss_attach(struct ciss_softc *sc)
 
 	mutex_exit(&sc->sc_mutex_scratch);
 
+	if (sc->maxunits == 0) {
+		bus_dmamem_free(sc->sc_dmat, sc->cmdseg, 1);
+		bus_dmamap_destroy(sc->sc_dmat, sc->cmdmap);
+		aprint_error_dev(sc->sc_dev,
+		    "No any LD. This driver can't attach.\n");
+		return -1;
+	}
+
 	callout_init(&sc->sc_hb, 0);
 	callout_setfunc(&sc->sc_hb, ciss_heartbeat, sc);
 	callout_schedule(&sc->sc_hb, hz * 3);

Reply via email to