From 3a69a23a33a36a98fb03119238232071c6a18aed Mon Sep 17 00:00:00 2001 From: krw Date: Wed, 23 Mar 2022 14:36:01 +0000 Subject: [PATCH] When configuring a scsi_link that has passed dev_probe() but fallen at one of the subsequent hurdles of scsi_probe_link() don't partially replicate scsi_discard_link(). Just call scsi_discard_link(). It now handles such partially configured scsi_link's. --- sys/scsi/scsiconf.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/sys/scsi/scsiconf.c b/sys/scsi/scsiconf.c index 941fdd6661f..7847ce73417 100644 --- a/sys/scsi/scsiconf.c +++ b/sys/scsi/scsiconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsiconf.c,v 1.246 2022/03/22 16:29:58 krw Exp $ */ +/* $OpenBSD: scsiconf.c,v 1.247 2022/03/23 14:36:01 krw Exp $ */ /* $NetBSD: scsiconf.c,v 1.57 1996/05/02 01:09:01 neil Exp $ */ /* @@ -519,7 +519,8 @@ scsi_probe_link(struct scsibus_softc *sb, int target, int lun, int dumbscan) SC_DEBUG(link, SDEV_DB2, ("dev_probe(link) failed.\n")); rslt = EINVAL; } - goto free; + free(link, M_DEVBUF, sizeof(*link)); + return rslt; } /* @@ -622,7 +623,7 @@ scsi_probe_link(struct scsibus_softc *sb, int target, int lun, int dumbscan) /* The device doesn't distinguish between LUNs. */ SC_DEBUG(link, SDEV_DB1, ("IDENTIFY not supported.\n")); rslt = EINVAL; - goto free_devid; + goto bad; } link->quirks = devquirks; /* Restore what the device wanted. */ @@ -679,7 +680,7 @@ scsi_probe_link(struct scsibus_softc *sb, int target, int lun, int dumbscan) if (cf == NULL) { scsibussubprint(&sa, sb->sc_dev.dv_xname); printf(" not configured\n"); - goto free_devid; + goto bad; } /* @@ -717,17 +718,8 @@ scsi_probe_link(struct scsibus_softc *sb, int target, int lun, int dumbscan) config_attach((struct device *)sb, cf, &sa, scsibussubprint); return 0; -free_devid: - if (link->id) - devid_free(link->id); bad: - if (ISSET(link->flags, SDEV_OWN_IOPL)) - free(link->pool, M_DEVBUF, sizeof(*link->pool)); - - if (sb->sb_adapter->dev_free != NULL) - sb->sb_adapter->dev_free(link); -free: - free(link, M_DEVBUF, sizeof(*link)); + scsi_detach_link(link, DETACH_FORCE); return rslt; } -- 2.20.1