shithub: riscv

Download patch

ref: 9efcce402b4c7b16b86bfd612fa35ea0d536da2b
parent: 662ab3b7b262e5da477c5e416de3609d524775c6
author: Jacob Moody <moody@posixcafe.org>
date: Fri May 26 16:32:22 EDT 2023

sdiahci, sdodin: more unconfigure panic fixes

--- a/sys/src/9/pc/sdiahci.c
+++ b/sys/src/9/pc/sdiahci.c
@@ -170,7 +170,7 @@
 };
 
 static	Ctlr	iactlr[NCtlr];
-static	SDev	sdevs[NCtlr];
+static	SDev	*sdevs;
 static	int	niactlr;
 
 static	Drive	*iadrive[NDrive];
@@ -2167,6 +2167,9 @@
 	}
 
 	memset(olds, 0xff, sizeof olds);
+	sdevs = malloc(sizeof(SDev)*NCtlr);
+	if(sdevs == nil)
+		return nil;
 	p = nil;
 	while((p = pcimatch(p, 0, 0)) != nil){
 		if((type = didtype(p)) == -1)
--- a/sys/src/9/pc/sdodin.c
+++ b/sys/src/9/pc/sdodin.c
@@ -543,7 +543,7 @@
 };
 
 static	Ctlr	msctlr[Nctlr];
-static	SDev	sdevs[Nctlr];
+static	SDev	*sdevs;
 static	uint	nmsctlr;
 static	Drive	*msdrive[Ndrive];
 static	uint	nmsdrive;
@@ -2646,6 +2646,9 @@
 		return nil;
 	s0 = nil;
 	ll = &s0;
+	sdevs = malloc(sizeof(SDev)*NCtlr);
+	if(sdevs == nil)
+		return nil;
 	for(p = nil; (p = pcimatch(p, 0x11ab, 0x6485)) != nil; ){
 		if(nmsctlr == Nctlr){
 			print("sdodin: too many controllers\n");