diff options
author | Toomas Soome <tsoome@FreeBSD.org> | 2017-09-12 14:18:45 +0000 |
---|---|---|
committer | Toomas Soome <tsoome@FreeBSD.org> | 2017-09-12 14:18:45 +0000 |
commit | c7847a364a9c559e5b092d1ad34c578e931427d8 (patch) | |
tree | ab3c971e03314ba2a5bebb5fe5d7551b45376377 /sys/boot/efi | |
parent | c7901210fb886110b94a83a0600f5f396359b9dc (diff) |
libefi: efipart_open should check the status from disk_open
In case of error from disk_open(), we should clean up properly.
Reviewed by: allanjude, imp
Differential Revision: https://reviews.freebsd.org/D12340
Notes
Notes:
svn path=/head/; revision=323497
Diffstat (limited to 'sys/boot/efi')
-rw-r--r-- | sys/boot/efi/libefi/efipart.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/sys/boot/efi/libefi/efipart.c b/sys/boot/efi/libefi/efipart.c index d1235dc7b732..dfea3b111fd8 100644 --- a/sys/boot/efi/libefi/efipart.c +++ b/sys/boot/efi/libefi/efipart.c @@ -723,9 +723,20 @@ efipart_open(struct open_file *f, ...) pd->pd_bcache = bcache_allocate(); if (dev->d_dev->dv_type == DEVT_DISK) { - return (disk_open(dev, + int rc; + + rc = disk_open(dev, blkio->Media->BlockSize * (blkio->Media->LastBlock + 1), - blkio->Media->BlockSize)); + blkio->Media->BlockSize); + if (rc != 0) { + pd->pd_open--; + if (pd->pd_open == 0) { + pd->pd_blkio = NULL; + bcache_free(pd->pd_bcache); + pd->pd_bcache = NULL; + } + } + return (rc); } return (0); } |