From: krw Date: Mon, 28 Mar 2022 15:47:11 +0000 (+0000) Subject: Only SLIST_REMOVE() a link when the link is on the list. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=6b0fbbfd38cde06649fbb87435b1ffea39c2dac3;p=openbsd Only SLIST_REMOVE() a link when the link is on the list. Avoids a potential panic. --- 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