Skip to content

Commit 850c3f1

Browse files
maurizio-lombardidwsuse
authored andcommitted
util: fix a file handle leak in nvme_uuid_random()
Signed-off-by: Maurizio Lombardi <[email protected]>
1 parent 1fb9973 commit 850c3f1

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

src/nvme/util.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -871,13 +871,11 @@ int nvme_uuid_random(unsigned char uuid[NVME_UUID_LEN])
871871
if (f < 0)
872872
return -errno;
873873
n = read(f, uuid, NVME_UUID_LEN);
874-
if (n < 0) {
875-
close(f);
874+
close(f);
875+
if (n < 0)
876876
return -errno;
877-
} else if (n != NVME_UUID_LEN) {
878-
close(f);
877+
else if (n != NVME_UUID_LEN)
879878
return -EIO;
880-
}
881879

882880
/*
883881
* See https://www.rfc-editor.org/rfc/rfc4122#section-4.4

0 commit comments

Comments
 (0)