From: jsg Date: Tue, 28 May 2024 00:24:44 +0000 (+0000) Subject: avoid uninitialised var use when scsi_get_link() returns NULL X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=9a0b8a7eed13bc7f82c216776a74a93294d526c2;p=openbsd avoid uninitialised var use when scsi_get_link() returns NULL found by smatch, ok krw@ --- diff --git a/sys/dev/ic/nvme.c b/sys/dev/ic/nvme.c index fd31bcf2a11..10688918698 100644 --- a/sys/dev/ic/nvme.c +++ b/sys/dev/ic/nvme.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nvme.c,v 1.114 2024/05/27 14:46:26 krw Exp $ */ +/* $OpenBSD: nvme.c,v 1.115 2024/05/28 00:24:44 jsg Exp $ */ /* * Copyright (c) 2014 David Gwynne @@ -1897,12 +1897,12 @@ nvme_bioctl_sdname(const struct nvme_softc *sc, int target) const struct sd_softc *sd; link = scsi_get_link(sc->sc_scsibus, target, 0); - if (link) { - sd = (struct sd_softc *)(link->device_softc); - if (ISSET(link->state, SDEV_S_DYING) || sd == NULL || - ISSET(sd->flags, SDF_DYING)) - return NULL; - } + if (link == NULL) + return NULL; + sd = (struct sd_softc *)(link->device_softc); + if (ISSET(link->state, SDEV_S_DYING) || sd == NULL || + ISSET(sd->flags, SDF_DYING)) + return NULL; if (nvme_read4(sc, NVME_VS) == 0xffffffff) return NULL;