diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2022-03-28 15:47:12 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2022-03-28 15:47:12 +0000 |
commit | a8ff3643d5f32dcf1b80d662cad63686bc94bc1a (patch) | |
tree | d61c9669ed96f75955fb9a178f89fa0ad74b5b5b | |
parent | f5458032115d2f397e03f874ab034e400453beae (diff) |
Only SLIST_REMOVE() a link when the link is on the list.
Avoids a potential panic.
-rw-r--r-- | sys/scsi/scsiconf.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/sys/scsi/scsiconf.c b/sys/scsi/scsiconf.c index a5450001ee4..3514716e96d 100644 --- a/sys/scsi/scsiconf.c +++ b/sys/scsi/scsiconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsiconf.c,v 1.248 2022/03/24 00:30:51 krw Exp $ */ +/* $OpenBSD: scsiconf.c,v 1.249 2022/03/28 15:47:11 krw Exp $ */ /* $NetBSD: scsiconf.c,v 1.57 1996/05/02 01:09:01 neil Exp $ */ /* @@ -850,7 +850,16 @@ scsi_add_link(struct scsi_link *link) void scsi_remove_link(struct scsi_link *link) { - SLIST_REMOVE(&link->bus->sc_link_list, link, scsi_link, bus_list); + struct scsibus_softc *sb = link->bus; + struct scsi_link *elm, *tmp; + + SLIST_FOREACH_SAFE(elm, &sb->sc_link_list, bus_list, tmp) { + if (elm == link) { + SLIST_REMOVE(&sb->sc_link_list, elm, scsi_link, + bus_list); + break; + } + } } void |