git: 787df454c817 - main - stabd/geli: Bail out if you can't get the disks size

From: Warner Losh <imp_at_FreeBSD.org>
Date: Fri, 21 Oct 2022 23:44:22 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=787df454c8175e58131f582c05c169070fb6ca7c

commit 787df454c8175e58131f582c05c169070fb6ca7c
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2022-10-21 23:39:34 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2022-10-21 23:39:34 +0000

    stabd/geli: Bail out if you can't get the disks size
    
    If the DIOCGMEDIASIZE ioctl fails, assume the disk doesn't have geli
    encryption. While all disks should implement this, fail safe for disks /
    partitions that do not.
    
    Sponsored by:           Netflix
---
 stand/libsa/geli/gelidev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/stand/libsa/geli/gelidev.c b/stand/libsa/geli/gelidev.c
index 5f1143399fb3..2dd686c81883 100644
--- a/stand/libsa/geli/gelidev.c
+++ b/stand/libsa/geli/gelidev.c
@@ -302,7 +302,8 @@ geli_probe_and_attach(struct open_file *f)
 	hdesc = (struct disk_devdesc *)(f->f_devdata);
 
 	/* Get the last block number for the host provider. */
-	hdesc->dd.d_dev->dv_ioctl(f, DIOCGMEDIASIZE, &hmediasize);
+	if (hdesc->dd.d_dev->dv_ioctl(f, DIOCGMEDIASIZE, &hmediasize) != 0)
+		return;
 	hlastblk = (hmediasize / DEV_BSIZE) - 1;
 
 	/* Taste the host provider.  If it's not geli-encrypted just return. */