summaryrefslogtreecommitdiff
path: root/sys/scsi
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2022-04-06 17:39:14 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2022-04-06 17:39:14 +0000
commit90576ca3c44963267c861feb5432ae35c1ccd46b (patch)
tree6a7c1af6b19d9c4d4311dde76d1409450a1ca428 /sys/scsi
parentdf1eddd314f7b2f46263208ce80144db56ba80a7 (diff)
Avoid traversing SLIST twice to remove a link.
From millert@
Diffstat (limited to 'sys/scsi')
-rw-r--r--sys/scsi/scsiconf.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/sys/scsi/scsiconf.c b/sys/scsi/scsiconf.c
index 48648fc8ffa..ed0e1115b18 100644
--- a/sys/scsi/scsiconf.c
+++ b/sys/scsi/scsiconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scsiconf.c,v 1.252 2022/04/06 13:23:58 krw Exp $ */
+/* $OpenBSD: scsiconf.c,v 1.253 2022/04/06 17:39:13 krw Exp $ */
/* $NetBSD: scsiconf.c,v 1.57 1996/05/02 01:09:01 neil Exp $ */
/*
@@ -844,14 +844,17 @@ void
scsi_remove_link(struct scsi_link *link)
{
struct scsibus_softc *sb = link->bus;
- struct scsi_link *elm, *tmp;
+ struct scsi_link *elm, *prev = NULL;
- SLIST_FOREACH_SAFE(elm, &sb->sc_link_list, bus_list, tmp) {
+ SLIST_FOREACH(elm, &sb->sc_link_list, bus_list) {
if (elm == link) {
- SLIST_REMOVE(&sb->sc_link_list, elm, scsi_link,
- bus_list);
+ if (prev == NULL)
+ SLIST_REMOVE_HEAD(&sb->sc_link_list, bus_list);
+ else
+ SLIST_REMOVE_AFTER(prev, bus_list);
break;
}
+ prev = elm;
}
}