Module Name: src
Committed By: jdc
Date: Sun May 3 06:31:02 UTC 2020
Modified Files:
src/sys/dev/sun: disksubr.c
Log Message:
If the sector size is 0, return early in readdisklabel().
Prevents a panic trying to use a 0-sized buffer, which can happen if we run
(e.g.) `scsictl /dev/cd0c identify` with no medium in the CD drive.
To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/sun/disksubr.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/sun/disksubr.c
diff -u src/sys/dev/sun/disksubr.c:1.16 src/sys/dev/sun/disksubr.c:1.17
--- src/sys/dev/sun/disksubr.c:1.16 Wed Apr 3 22:10:52 2019
+++ src/sys/dev/sun/disksubr.c Sun May 3 06:31:02 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: disksubr.c,v 1.16 2019/04/03 22:10:52 christos Exp $ */
+/* $NetBSD: disksubr.c,v 1.17 2020/05/03 06:31:02 jdc Exp $ */
/*
* Copyright (c) 1982, 1986, 1988 Regents of the University of California.
@@ -55,7 +55,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.16 2019/04/03 22:10:52 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.17 2020/05/03 06:31:02 jdc Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -104,6 +104,8 @@ readdisklabel(dev_t dev, void (*strat)(s
lp->d_partitions[RAW_PART].p_size = 0x1fffffff;
lp->d_partitions[RAW_PART].p_offset = 0;
}
+ if (lp->d_secsize == 0)
+ return ("sector size 0");
/* obtain buffer to probe drive with */
bp = geteblk((int)lp->d_secsize);