diff options
-rw-r--r-- | sys/arch/alpha/alpha/disksubr.c | 9 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/disksubr.c | 8 | ||||
-rw-r--r-- | sys/arch/arm/arm/disksubr.c | 8 | ||||
-rw-r--r-- | sys/arch/aviion/aviion/disksubr.c | 8 | ||||
-rw-r--r-- | sys/arch/hp300/hp300/disksubr.c | 20 | ||||
-rw-r--r-- | sys/arch/hppa/hppa/disksubr.c | 9 | ||||
-rw-r--r-- | sys/arch/hppa64/hppa64/disksubr.c | 9 | ||||
-rw-r--r-- | sys/arch/i386/i386/disksubr.c | 8 | ||||
-rw-r--r-- | sys/arch/landisk/landisk/disksubr.c | 8 | ||||
-rw-r--r-- | sys/arch/luna88k/luna88k/disksubr.c | 49 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/disksubr.c | 19 | ||||
-rw-r--r-- | sys/arch/macppc/macppc/disksubr.c | 16 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/disksubr.c | 9 | ||||
-rw-r--r-- | sys/arch/mvme68k/mvme68k/disksubr.c | 52 | ||||
-rw-r--r-- | sys/arch/mvme88k/mvme88k/disksubr.c | 52 | ||||
-rw-r--r-- | sys/arch/mvmeppc/mvmeppc/disksubr.c | 16 | ||||
-rw-r--r-- | sys/arch/sparc/sparc/disksubr.c | 69 | ||||
-rw-r--r-- | sys/arch/sparc64/sparc64/disksubr.c | 69 | ||||
-rw-r--r-- | sys/arch/vax/vax/disksubr.c | 19 |
19 files changed, 299 insertions, 158 deletions
diff --git a/sys/arch/alpha/alpha/disksubr.c b/sys/arch/alpha/alpha/disksubr.c index 387f8156a67..141dd05afea 100644 --- a/sys/arch/alpha/alpha/disksubr.c +++ b/sys/arch/alpha/alpha/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.67 2007/02/18 14:18:28 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.68 2007/05/29 05:08:19 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -141,8 +141,10 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) lp->d_secsize = DEV_BSIZE; if (lp->d_secperunit == 0) lp->d_secperunit = 0x1fffffff; - if (lp->d_secpercyl == 0) - return ("invalid geometry"); + if (lp->d_secpercyl == 0) { + msg = "invalid geometry"; + goto done; + } lp->d_npartitions = RAW_PART + 1; for (i = 0; i < RAW_PART; i++) { lp->d_partitions[i].p_size = 0; @@ -187,6 +189,7 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) if (msg) *lp = fallbacklabel; +done: if (bp) { bp->b_flags |= B_INVAL; brelse(bp); diff --git a/sys/arch/amd64/amd64/disksubr.c b/sys/arch/amd64/amd64/disksubr.c index 56cb3e71eba..d0395f77af6 100644 --- a/sys/arch/amd64/amd64/disksubr.c +++ b/sys/arch/amd64/amd64/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.31 2007/04/26 22:42:11 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.32 2007/05/29 05:08:19 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -87,8 +87,10 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, lp->d_secsize = DEV_BSIZE; if (lp->d_secperunit == 0) lp->d_secperunit = 0x1fffffff; - if (lp->d_secpercyl == 0) - return ("invalid geometry"); + if (lp->d_secpercyl == 0) { + msg = "invalid geometry"; + goto done; + } lp->d_npartitions = RAW_PART + 1; for (i = 0; i < RAW_PART; i++) { lp->d_partitions[i].p_size = 0; diff --git a/sys/arch/arm/arm/disksubr.c b/sys/arch/arm/arm/disksubr.c index 203528f064c..818d8e695c5 100644 --- a/sys/arch/arm/arm/disksubr.c +++ b/sys/arch/arm/arm/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.26 2007/02/18 13:49:22 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.27 2007/05/29 05:08:19 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -83,8 +83,10 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) lp->d_secsize = DEV_BSIZE; if (lp->d_secperunit == 0) lp->d_secperunit = 0x1fffffff; - if (lp->d_secpercyl == 0) - return ("invalid geometry"); + if (lp->d_secpercyl == 0) { + msg = "invalid geometry"; + goto done; + } lp->d_npartitions = RAW_PART + 1; for (i = 0; i < RAW_PART; i++) { lp->d_partitions[i].p_size = 0; diff --git a/sys/arch/aviion/aviion/disksubr.c b/sys/arch/aviion/aviion/disksubr.c index d2359312979..000ff6aa2c1 100644 --- a/sys/arch/aviion/aviion/disksubr.c +++ b/sys/arch/aviion/aviion/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.17 2007/02/18 13:49:22 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.18 2007/05/29 05:08:19 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -83,8 +83,10 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) lp->d_secsize = DEV_BSIZE; if (lp->d_secperunit == 0) lp->d_secperunit = 0x1fffffff; - if (lp->d_secpercyl == 0) - return ("invalid geometry"); + if (lp->d_secpercyl == 0) { + msg = "invalid geometry"; + goto done; + } lp->d_npartitions = RAW_PART + 1; for (i = 0; i < RAW_PART; i++) { lp->d_partitions[i].p_size = 0; diff --git a/sys/arch/hp300/hp300/disksubr.c b/sys/arch/hp300/hp300/disksubr.c index 8f0a8346a16..025a2e5b57e 100644 --- a/sys/arch/hp300/hp300/disksubr.c +++ b/sys/arch/hp300/hp300/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.23 2006/10/29 14:12:21 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.24 2007/05/29 05:08:19 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.9 1997/04/01 03:12:13 scottr Exp $ */ /* @@ -59,7 +59,7 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) struct cpu_disklabel *osdep; int spoofonly; { - struct buf *bp; + struct buf *bp = NULL; struct disklabel *dlp; int i; char *msg = NULL; @@ -69,8 +69,10 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) lp->d_secsize = DEV_BSIZE; if (lp->d_secperunit == 0) lp->d_secperunit = 0x1fffffff; - if (lp->d_secpercyl == 0) - return ("invalid geometry"); + if (lp->d_secpercyl == 0) { + msg = "invalid geometry"; + goto done; + } lp->d_npartitions = RAW_PART + 1; for (i = 0; i < RAW_PART; i++) { lp->d_partitions[i].p_size = 0; @@ -82,7 +84,7 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) /* don't read the on-disk label if we are in spoofed-only mode */ if (spoofonly) - return (NULL); + goto done; bp = geteblk((int)lp->d_secsize); bp->b_dev = dev; @@ -117,8 +119,12 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) break; } } - bp->b_flags = B_INVAL | B_AGE; - brelse(bp); + +done: + if (bp) { + bp->b_flags = B_INVAL | B_AGE; + brelse(bp); + } return (msg); } diff --git a/sys/arch/hppa/hppa/disksubr.c b/sys/arch/hppa/hppa/disksubr.c index e1ab72b0e2b..313649991d2 100644 --- a/sys/arch/hppa/hppa/disksubr.c +++ b/sys/arch/hppa/hppa/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.47 2007/02/18 14:18:28 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.48 2007/05/29 05:08:19 krw Exp $ */ /* * Copyright (c) 1999 Michael Shalayeff @@ -145,8 +145,10 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) lp->d_secsize = DEV_BSIZE; if (lp->d_secperunit == 0) lp->d_secperunit = 0x1fffffff; - if (lp->d_secpercyl == 0) - return ("invalid geometry"); + if (lp->d_secpercyl == 0) { + msg = "invalid geometry"; + goto done; + } lp->d_npartitions = RAW_PART + 1; for (i = 0; i < RAW_PART; i++) { lp->d_partitions[i].p_size = 0; @@ -190,6 +192,7 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) if (msg) *lp = fallbacklabel; +done: if (bp) { bp->b_flags |= B_INVAL; brelse(bp); diff --git a/sys/arch/hppa64/hppa64/disksubr.c b/sys/arch/hppa64/hppa64/disksubr.c index bc875ebd609..60bba818722 100644 --- a/sys/arch/hppa64/hppa64/disksubr.c +++ b/sys/arch/hppa64/hppa64/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.30 2007/02/18 14:18:28 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.31 2007/05/29 05:08:19 krw Exp $ */ /* * Copyright (c) 1999 Michael Shalayeff @@ -145,8 +145,10 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) lp->d_secsize = DEV_BSIZE; if (lp->d_secperunit == 0) lp->d_secperunit = 0x1fffffff; - if (lp->d_secpercyl == 0) - return ("invalid geometry"); + if (lp->d_secpercyl == 0) { + msg = "invalid geometry"; + goto done; + } lp->d_npartitions = RAW_PART + 1; for (i = 0; i < RAW_PART; i++) { lp->d_partitions[i].p_size = 0; @@ -186,6 +188,7 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) if (msg) *lp = fallbacklabel; +done: if (bp) { bp->b_flags |= B_INVAL; brelse(bp); diff --git a/sys/arch/i386/i386/disksubr.c b/sys/arch/i386/i386/disksubr.c index c381c933fe1..ec7e97d05a7 100644 --- a/sys/arch/i386/i386/disksubr.c +++ b/sys/arch/i386/i386/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.71 2007/04/26 22:42:11 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.72 2007/05/29 05:08:20 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -87,8 +87,10 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, lp->d_secsize = DEV_BSIZE; if (lp->d_secperunit == 0) lp->d_secperunit = 0x1fffffff; - if (lp->d_secpercyl == 0) - return ("invalid geometry"); + if (lp->d_secpercyl == 0) { + msg = "invalid geometry"; + goto done; + } lp->d_npartitions = RAW_PART + 1; for (i = 0; i < RAW_PART; i++) { lp->d_partitions[i].p_size = 0; diff --git a/sys/arch/landisk/landisk/disksubr.c b/sys/arch/landisk/landisk/disksubr.c index 926922e2095..c176cae4e4a 100644 --- a/sys/arch/landisk/landisk/disksubr.c +++ b/sys/arch/landisk/landisk/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.14 2007/02/18 13:49:22 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.15 2007/05/29 05:08:20 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -83,8 +83,10 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) lp->d_secsize = DEV_BSIZE; if (lp->d_secperunit == 0) lp->d_secperunit = 0x1fffffff; - if (lp->d_secpercyl == 0) - return ("invalid geometry"); + if (lp->d_secpercyl == 0) { + msg = "invalid geometry"; + goto done; + } lp->d_npartitions = RAW_PART + 1; for (i = 0; i < RAW_PART; i++) { lp->d_partitions[i].p_size = 0; diff --git a/sys/arch/luna88k/luna88k/disksubr.c b/sys/arch/luna88k/luna88k/disksubr.c index f3f155b76e3..9168329f120 100644 --- a/sys/arch/luna88k/luna88k/disksubr.c +++ b/sys/arch/luna88k/luna88k/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.10 2006/10/04 03:23:01 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.11 2007/05/29 05:08:20 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.12 2002/02/19 17:09:44 wiz Exp $ */ /* @@ -119,9 +119,10 @@ readdisklabel(dev, strat, lp, clp, spoofonly) struct cpu_disklabel *clp; int spoofonly; { - struct buf *bp; + struct buf *bp = NULL; struct disklabel *dlp; struct sun_disklabel *slp; + char *msg = NULL; int error, i; /* minimal requirements for archetypal disk label */ @@ -129,8 +130,10 @@ readdisklabel(dev, strat, lp, clp, spoofonly) lp->d_secsize = DEV_BSIZE; if (lp->d_secperunit == 0) lp->d_secperunit = 0x1fffffff; - if (lp->d_secpercyl == 0) - return ("invalid geometry"); + if (lp->d_secpercyl == 0) { + msg = "invalid geometry"; + goto done; + } lp->d_npartitions = RAW_PART + 1; for (i = 0; i < RAW_PART; i++) { lp->d_partitions[i].p_size = 0; @@ -142,7 +145,7 @@ readdisklabel(dev, strat, lp, clp, spoofonly) /* don't read the on-disk label if we are in spoofed-only mode */ if (spoofonly) - return (NULL); + goto done; /* obtain buffer to probe drive with */ bp = geteblk((int)lp->d_secsize); @@ -161,18 +164,22 @@ readdisklabel(dev, strat, lp, clp, spoofonly) /* Save the whole block in case it has info we need. */ bcopy(bp->b_data, clp->cd_block, sizeof(clp->cd_block)); } - bp->b_flags = B_INVAL | B_AGE | B_READ; - brelse(bp); - if (error) - return ("disk label read error"); + if (error) { + msg = "disk label read error"; + goto done; + } #if defined(CD9660) - if (iso_disklabelspoof(dev, strat, lp) == 0) - return (NULL); + if (iso_disklabelspoof(dev, strat, lp) == 0) { + msg = NULL; + goto done; + } #endif #if defined(UDF) - if (udf_disklabelspoof(dev, strat, lp) == 0) - return (NULL); + if (udf_disklabelspoof(dev, strat, lp) == 0) { + msg = NULL; + goto done; + } #endif /* Check for a BSD disk label first. */ @@ -180,7 +187,8 @@ readdisklabel(dev, strat, lp, clp, spoofonly) if (dlp->d_magic == DISKMAGIC && dlp->d_magic2 == DISKMAGIC) { if (dkcksum(dlp) == 0) { *lp = *dlp; /* struct assignment */ - return (NULL); + msg = NULL; + goto done; } printf("BSD disk label corrupted"); } @@ -188,11 +196,20 @@ readdisklabel(dev, strat, lp, clp, spoofonly) /* Check for a UniOS/ISI disk label. */ slp = (struct sun_disklabel *)clp->cd_block; if (slp->sl_magic == SUN_DKMAGIC) { - return (disklabel_om_to_bsd(clp->cd_block, lp)); + msg = disklabel_om_to_bsd(clp->cd_block, lp); + goto done; } memset(clp->cd_block, 0, sizeof(clp->cd_block)); - return ("no disk label"); + msg = "no disk label"; + +done: + if (bp) { + bp->b_flags = B_INVAL | B_AGE | B_READ; + brelse(bp); + } + return (msg); + } /* diff --git a/sys/arch/mac68k/mac68k/disksubr.c b/sys/arch/mac68k/mac68k/disksubr.c index e1f9d0f064e..84ec4f989c3 100644 --- a/sys/arch/mac68k/mac68k/disksubr.c +++ b/sys/arch/mac68k/mac68k/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.31 2006/09/24 22:43:00 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.32 2007/05/29 05:08:20 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.22 1997/11/26 04:18:20 briggs Exp $ */ /* @@ -364,7 +364,7 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) struct cpu_disklabel *osdep; int spoofonly; { - struct buf *bp; + struct buf *bp = NULL; char *msg = NULL; struct disklabel *dlp; int i, size; @@ -374,8 +374,10 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) lp->d_secsize = DEV_BSIZE; if (lp->d_secperunit == 0) lp->d_secperunit = 0x1fffffff; - if (lp->d_secpercyl == 0) - return ("invalid geometry"); + if (lp->d_secpercyl == 0) { + msg = "invalid geometry"; + goto done; + } lp->d_npartitions = RAW_PART + 1; for (i = 0; i < RAW_PART; i++) { lp->d_partitions[i].p_size = 0; @@ -387,7 +389,7 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) /* don't read the on-disk label if we are in spoofed-only mode */ if (spoofonly) - return (NULL); + goto done; size = roundup((NUM_PARTS_PROBED + 1) << DEV_BSHIFT, lp->d_secsize); bp = geteblk(size); @@ -429,8 +431,11 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) msg = NULL; #endif - bp->b_flags |= B_INVAL; - brelse(bp); +done: + if (bp) { + bp->b_flags |= B_INVAL; + brelse(bp); + } return (msg); } diff --git a/sys/arch/macppc/macppc/disksubr.c b/sys/arch/macppc/macppc/disksubr.c index b5201c6795a..8b274d31fe2 100644 --- a/sys/arch/macppc/macppc/disksubr.c +++ b/sys/arch/macppc/macppc/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.36 2007/02/18 13:49:22 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.37 2007/05/29 05:08:20 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -71,7 +71,7 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *dlp; unsigned long extoff = 0; unsigned int fattest; - struct buf *bp; + struct buf *bp = NULL; daddr_t part_blkno = DOSBBSECTOR; char *msg = NULL; char *s; @@ -87,8 +87,10 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *), lp->d_secsize = DEV_BSIZE; if (lp->d_secperunit == 0) lp->d_secperunit = 0x1fffffff; - if (lp->d_secpercyl == 0) - return ("invalid geometry"); + if (lp->d_secpercyl == 0) { + msg = "invalid geometry"; + goto done; + } lp->d_npartitions = RAW_PART + 1; for (i = 0; i < RAW_PART; i++) { lp->d_partitions[i].p_size = 0; @@ -375,8 +377,10 @@ found_disklabel: #endif done: - bp->b_flags |= B_INVAL; - brelse(bp); + if (bp) { + bp->b_flags |= B_INVAL; + brelse(bp); + } return (msg); } diff --git a/sys/arch/mips64/mips64/disksubr.c b/sys/arch/mips64/mips64/disksubr.c index 1edc6b9d6d8..f48e84212a2 100644 --- a/sys/arch/mips64/mips64/disksubr.c +++ b/sys/arch/mips64/mips64/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.36 2007/02/18 14:18:28 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.37 2007/05/29 05:08:20 krw Exp $ */ /* * Copyright (c) 1999 Michael Shalayeff @@ -146,8 +146,10 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) lp->d_secsize = DEV_BSIZE; if (lp->d_secperunit == 0) lp->d_secperunit = 0x1fffffff; - if (lp->d_secpercyl == 0) - return ("invalid geometry"); + if (lp->d_secpercyl == 0) { + msg = "invalid geometry"; + goto done; + } lp->d_npartitions = RAW_PART + 1; for (i = 0; i < RAW_PART; i++) { lp->d_partitions[i].p_size = 0; @@ -194,6 +196,7 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) if (msg) *lp = fallbacklabel; +done: if (bp) { bp->b_flags |= B_INVAL; brelse(bp); diff --git a/sys/arch/mvme68k/mvme68k/disksubr.c b/sys/arch/mvme68k/mvme68k/disksubr.c index 06c2c003e9f..1dd4d51b7b2 100644 --- a/sys/arch/mvme68k/mvme68k/disksubr.c +++ b/sys/arch/mvme68k/mvme68k/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.37 2006/10/21 16:01:54 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.38 2007/05/29 05:08:20 krw Exp $ */ /* * Copyright (c) 1998 Steve Murphree, Jr. * Copyright (c) 1995 Dale Rahn. @@ -65,7 +65,8 @@ readdisklabel(dev, strat, lp, clp, spoofonly) struct cpu_disklabel *clp; int spoofonly; { - struct buf *bp; + struct buf *bp = NULL; + char *msg = NULL; int error, i; /* minimal requirements for archetypal disk label */ @@ -73,8 +74,10 @@ readdisklabel(dev, strat, lp, clp, spoofonly) lp->d_secsize = DEV_BSIZE; if (lp->d_secperunit == 0) lp->d_secperunit = 0x1fffffff; - if (lp->d_secpercyl == 0) - return ("invalid geometry"); + if (lp->d_secpercyl == 0) { + msg = "invalid geometry"; + goto done; + } lp->d_npartitions = RAW_PART + 1; for (i = 0; i < RAW_PART; i++) { lp->d_partitions[i].p_size = 0; @@ -86,7 +89,7 @@ readdisklabel(dev, strat, lp, clp, spoofonly) /* don't read the on-disk label if we are in spoofed-only mode */ if (spoofonly) - return (NULL); + goto done; /* obtain buffer to probe drive with */ bp = geteblk((int)lp->d_secsize); @@ -102,28 +105,36 @@ readdisklabel(dev, strat, lp, clp, spoofonly) error = biowait(bp); if (error == 0) bcopy(bp->b_data, clp, sizeof (struct cpu_disklabel)); - bp->b_flags = B_INVAL | B_AGE | B_READ; - brelse(bp); - if (error) - return ("disk label read error"); + if (error) { + msg = "disk label read error"; + goto done; + } #if defined(CD9660) - if (iso_disklabelspoof(dev, strat, lp) == 0) - return (NULL); + if (iso_disklabelspoof(dev, strat, lp) == 0) { + msg = NULL; + goto done; + } #endif #if defined(UDF) - if (udf_disklabelspoof(dev, strat, lp) == 0) - return (NULL); + if (udf_disklabelspoof(dev, strat, lp) == 0) { + msg = NULL; + goto done; + } #endif - if (clp->magic1 != DISKMAGIC || clp->magic2 != DISKMAGIC) - return ("no disk label"); + if (clp->magic1 != DISKMAGIC || clp->magic2 != DISKMAGIC) { + msg = "no disk label"; + goto done; + } cputobsdlabel(lp, clp); - if (dkcksum(lp) != 0) - return ("disk label corrupted"); + if (dkcksum(lp) != 0) { + msg = "disk label corrupted"; + goto done; + } #ifdef DEBUG if (disksubr_debug > 0) { @@ -131,7 +142,12 @@ readdisklabel(dev, strat, lp, clp, spoofonly) printclp(clp, "readdisklabel:cpu label"); } #endif - return (NULL); +done: + if (bp) { + bp->b_flags = B_INVAL | B_AGE | B_READ; + brelse(bp); + } + return (msg); } /* diff --git a/sys/arch/mvme88k/mvme88k/disksubr.c b/sys/arch/mvme88k/mvme88k/disksubr.c index 7569c5a1635..04dbd071675 100644 --- a/sys/arch/mvme88k/mvme88k/disksubr.c +++ b/sys/arch/mvme88k/mvme88k/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.33 2006/08/17 10:34:14 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.34 2007/05/29 05:08:20 krw Exp $ */ /* * Copyright (c) 1998 Steve Murphree, Jr. * Copyright (c) 1995 Dale Rahn. @@ -63,7 +63,8 @@ readdisklabel(dev, strat, lp, clp, spoofonly) struct cpu_disklabel *clp; int spoofonly; { - struct buf *bp; + struct buf *bp = NULL; + char *msg = NULL; int error, i; /* minimal requirements for archetypal disk label */ @@ -71,8 +72,10 @@ readdisklabel(dev, strat, lp, clp, spoofonly) lp->d_secsize = DEV_BSIZE; if (lp->d_secperunit == 0) lp->d_secperunit = 0x1fffffff; - if (lp->d_secpercyl == 0) - return ("invalid geometry"); + if (lp->d_secpercyl == 0) { + msg = "invalid geometry"; + goto done; + } lp->d_npartitions = RAW_PART + 1; for (i = 0; i < RAW_PART; i++) { lp->d_partitions[i].p_size = 0; @@ -84,7 +87,7 @@ readdisklabel(dev, strat, lp, clp, spoofonly) /* don't read the on-disk label if we are in spoofed-only mode */ if (spoofonly) - return (NULL); + goto done; /* obtain buffer to probe drive with */ bp = geteblk((int)lp->d_secsize); @@ -100,27 +103,35 @@ readdisklabel(dev, strat, lp, clp, spoofonly) error = biowait(bp); if (error == 0) bcopy(bp->b_data, clp, sizeof (struct cpu_disklabel)); - bp->b_flags = B_INVAL | B_AGE | B_READ; - brelse(bp); - if (error) - return ("disk label read error"); + if (error) { + msg = "disk label read error"; + goto done; + } #if defined(CD9660) - if (iso_disklabelspoof(dev, strat, lp) == 0) - return (NULL); + if (iso_disklabelspoof(dev, strat, lp) == 0) { + msg = NULL; + goto done; + } #endif #if defined(UDF) - if (udf_disklabelspoof(dev, strat, lp) == 0) - return (NULL); + if (udf_disklabelspoof(dev, strat, lp) == 0) { + msg = NULL; + goto done; + } #endif - if (clp->magic1 != DISKMAGIC || clp->magic2 != DISKMAGIC) - return ("no disk label"); + if (clp->magic1 != DISKMAGIC || clp->magic2 != DISKMAGIC) { + msg = "no disk label"; + goto done; + } cputobsdlabel(lp, clp); - if (dkcksum(lp) != 0) - return ("disk label corrupted"); + if (dkcksum(lp) != 0) { + msg = "disk label corrupted"; + goto done; + } #ifdef DEBUG if (disksubr_debug != 0) { @@ -128,7 +139,12 @@ readdisklabel(dev, strat, lp, clp, spoofonly) printclp(clp, "readdisklabel:cpu label"); } #endif - return (NULL); +done: + if (bp) { + bp->b_flags = B_INVAL | B_AGE | B_READ; + brelse(bp); + } + return (msg); } /* diff --git a/sys/arch/mvmeppc/mvmeppc/disksubr.c b/sys/arch/mvmeppc/mvmeppc/disksubr.c index f3c7bec6ed4..0b538400c3a 100644 --- a/sys/arch/mvmeppc/mvmeppc/disksubr.c +++ b/sys/arch/mvmeppc/mvmeppc/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.32 2007/02/18 13:49:22 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.33 2007/05/29 05:08:20 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -75,7 +75,7 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) struct disklabel *dlp; unsigned long extoff = 0; unsigned int fattest; - struct buf *bp; + struct buf *bp = NULL; daddr_t part_blkno = DOSBBSECTOR; char *msg = NULL; int dospartoff, cyl, i, ourpart = -1; @@ -86,8 +86,10 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) lp->d_secsize = DEV_BSIZE; if (lp->d_secperunit == 0) lp->d_secperunit = 0x1fffffff; - if (lp->d_secpercyl == 0) - return ("invalid geometry"); + if (lp->d_secpercyl == 0) { + msg = "invalid geometry"; + goto done; + } lp->d_npartitions = RAW_PART + 1; for (i = 0; i < RAW_PART; i++) { lp->d_partitions[i].p_size = 0; @@ -289,8 +291,10 @@ notfat: #endif done: - bp->b_flags |= B_INVAL; - brelse(bp); + if (bp) { + bp->b_flags |= B_INVAL; + brelse(bp); + } return (msg); } diff --git a/sys/arch/sparc/sparc/disksubr.c b/sys/arch/sparc/sparc/disksubr.c index eeb663d25d0..8d9ceeaf2ac 100644 --- a/sys/arch/sparc/sparc/disksubr.c +++ b/sys/arch/sparc/sparc/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.42 2006/10/21 16:01:54 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.43 2007/05/29 05:08:20 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.16 1996/04/28 20:25:59 thorpej Exp $ */ /* @@ -78,9 +78,10 @@ readdisklabel(dev, strat, lp, clp, spoofonly) struct cpu_disklabel *clp; int spoofonly; { - struct buf *bp; + struct buf *bp = NULL; struct disklabel *dlp; struct sun_disklabel *slp; + char *msg = NULL; int error, i; /* minimal requirements for archetypal disk label */ @@ -88,8 +89,10 @@ readdisklabel(dev, strat, lp, clp, spoofonly) lp->d_secsize = DEV_BSIZE; if (lp->d_secperunit == 0) lp->d_secperunit = 0x1fffffff; - if (lp->d_secpercyl == 0) - return ("invalid geometry"); + if (lp->d_secpercyl == 0) { + msg = "invalid geometry"; + goto done; + } lp->d_npartitions = RAW_PART+1; for (i = 0; i < RAW_PART; i++) { lp->d_partitions[i].p_size = 0; @@ -103,7 +106,7 @@ readdisklabel(dev, strat, lp, clp, spoofonly) /* don't read the on-disk label if we are in spoofed-only mode */ if (spoofonly) - return (NULL); + goto done; /* obtain buffer to probe drive with */ bp = geteblk((int)lp->d_secsize); @@ -122,48 +125,68 @@ readdisklabel(dev, strat, lp, clp, spoofonly) /* Save the whole block in case it has info we need. */ bcopy(bp->b_data, clp->cd_block, sizeof(clp->cd_block)); } - bp->b_flags = B_INVAL | B_AGE | B_READ; - brelse(bp); - if (error) - return ("disk label read error"); + if (error) { + msg = "disk label read error"; + goto done; + } #if NCD > 0 if (strat == cdstrategy) { #if defined(CD9660) - if (iso_disklabelspoof(dev, strat, lp) == 0) - return (NULL); + if (iso_disklabelspoof(dev, strat, lp) == 0) { + msg = NULL; + goto done; + } #endif #if defined(UDF) - if (udf_disklabelspoof(dev, strat, lp) == 0) - return (NULL); + if (udf_disklabelspoof(dev, strat, lp) == 0) { + msg = NULL; + goto done; + } #endif } #endif /* NCD > 0 */ /* Check for a Sun disk label (for PROM compatibility). */ slp = (struct sun_disklabel *) clp->cd_block; - if (slp->sl_magic == SUN_DKMAGIC) - return (disklabel_sun_to_bsd(clp->cd_block, lp)); + if (slp->sl_magic == SUN_DKMAGIC) { + msg = disklabel_sun_to_bsd(clp->cd_block, lp); + goto done; + } /* Check for a native disk label (PROM can not boot it). */ dlp = (struct disklabel *) (clp->cd_block + LABELOFFSET); if (dlp->d_magic == DISKMAGIC) { - if (dkcksum(dlp)) - return ("disk label corrupted"); + if (dkcksum(dlp)) { + msg = "disk label corrupted"; + goto done; + } *lp = *dlp; /* struct assignment */ - return (NULL); + msg = NULL; + goto done; } #if defined(CD9660) - if (iso_disklabelspoof(dev, strat, lp) == 0) - return (NULL); + if (iso_disklabelspoof(dev, strat, lp) == 0) { + msg = NULL; + goto done; + } #endif #if defined(UDF) - if (udf_disklabelspoof(dev, strat, lp) == 0) - return (NULL); + if (udf_disklabelspoof(dev, strat, lp) == 0) { + msg = NULL; + goto done; + } #endif bzero(clp->cd_block, sizeof(clp->cd_block)); - return ("no disk label"); + msg = "no disk label"; + +done: + if (bp) { + bp->b_flags = B_INVAL | B_AGE | B_READ; + brelse(bp); + } + return (msg); } /* diff --git a/sys/arch/sparc64/sparc64/disksubr.c b/sys/arch/sparc64/sparc64/disksubr.c index 437d47e59af..b0b4987106b 100644 --- a/sys/arch/sparc64/sparc64/disksubr.c +++ b/sys/arch/sparc64/sparc64/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.20 2006/10/04 03:23:01 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.21 2007/05/29 05:08:20 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.13 2000/12/17 22:39:18 pk Exp $ */ /* @@ -78,9 +78,10 @@ readdisklabel(dev, strat, lp, clp, spoofonly) struct cpu_disklabel *clp; int spoofonly; { - struct buf *bp; + struct buf *bp = NULL; struct disklabel *dlp; struct sun_disklabel *slp; + char *msg = NULL; int error, i; /* minimal requirements for archetypal disk label */ @@ -88,8 +89,10 @@ readdisklabel(dev, strat, lp, clp, spoofonly) lp->d_secsize = DEV_BSIZE; if (lp->d_secperunit == 0) lp->d_secperunit = 0x1fffffff; - if (lp->d_secpercyl == 0) - return ("invalid geometry"); + if (lp->d_secpercyl == 0) { + msg = "invalid geometry"; + goto done; + } lp->d_npartitions = RAW_PART+1; for (i = 0; i < RAW_PART; i++) { lp->d_partitions[i].p_size = 0; @@ -103,17 +106,21 @@ readdisklabel(dev, strat, lp, clp, spoofonly) /* don't read the on-disk label if we are in spoofed-only mode */ if (spoofonly) - return (NULL); + goto done; #if NCD > 0 if (strat == cdstrategy) { #if defined(CD9660) - if (iso_disklabelspoof(dev, strat, lp) == 0) - return (NULL); + if (iso_disklabelspoof(dev, strat, lp) == 0) { + msg = NULL; + goto done; + } #endif #if defined(UDF) - if (udf_disklabelspoof(dev, strat, lp) == 0) - return (NULL); + if (udf_disklabelspoof(dev, strat, lp) == 0) { + msg = NULL; + goto done; + } #endif } #endif /* NCD > 0 */ @@ -135,34 +142,50 @@ readdisklabel(dev, strat, lp, clp, spoofonly) /* Save the whole block in case it has info we need. */ bcopy(bp->b_data, clp->cd_block, sizeof(clp->cd_block)); } - bp->b_flags = B_INVAL | B_AGE | B_READ; - brelse(bp); - if (error) - return ("disk label read error"); + if (error) { + msg = "disk label read error"; + goto done; + } slp = (struct sun_disklabel *) clp->cd_block; - if (slp->sl_magic == SUN_DKMAGIC) - return (disklabel_sun_to_bsd(clp->cd_block, lp)); + if (slp->sl_magic == SUN_DKMAGIC) { + msg = disklabel_sun_to_bsd(clp->cd_block, lp); + goto done; + } /* Check for a native disk label (PROM can not boot it). */ dlp = (struct disklabel *) (clp->cd_block + LABELOFFSET); if (dlp->d_magic == DISKMAGIC) { - if (dkcksum(dlp)) - return ("disk label corrupted"); + if (dkcksum(dlp)) { + msg = "disk label corrupted"; + goto done; + } *lp = *dlp; /* struct assignment */ - return (NULL); + msg = NULL; + goto done; } #if defined(CD9660) - if (iso_disklabelspoof(dev, strat, lp) == NULL) - return (NULL); + if (iso_disklabelspoof(dev, strat, lp) == NULL) { + msg = NULL; + goto done; + } #endif #if defined(UDF) - if (udf_disklabelspoof(dev, strat, lp) == 0) - return (NULL); + if (udf_disklabelspoof(dev, strat, lp) == 0) { + msg = NULL; + goto done; + } #endif bzero(clp->cd_block, sizeof(clp->cd_block)); - return ("no disk label"); + msg = "no disk label"; + +done: + if (bp) { + bp->b_flags = B_INVAL | B_AGE | B_READ; + brelse(bp); + } + return (msg); } /* diff --git a/sys/arch/vax/vax/disksubr.c b/sys/arch/vax/vax/disksubr.c index 5d5604e8a8c..59aa57f35af 100644 --- a/sys/arch/vax/vax/disksubr.c +++ b/sys/arch/vax/vax/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.33 2007/02/18 11:43:19 miod Exp $ */ +/* $OpenBSD: disksubr.c,v 1.34 2007/05/29 05:08:20 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1999/06/30 18:48:06 ragge Exp $ */ /* @@ -121,7 +121,7 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) struct cpu_disklabel *osdep; int spoofonly; { - struct buf *bp; + struct buf *bp = NULL; struct disklabel *dlp; char *msg = NULL; int i; @@ -131,8 +131,10 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) lp->d_secsize = DEV_BSIZE; if (lp->d_secperunit == 0) lp->d_secperunit = 0x1fffffff; - if (lp->d_secpercyl == 0) - return ("invalid geometry"); + if (lp->d_secpercyl == 0) { + msg = "invalid geometry"; + goto done; + } lp->d_npartitions = RAW_PART + 1; for (i = 0; i < RAW_PART; i++) { lp->d_partitions[i].p_size = 0; @@ -146,7 +148,7 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) /* don't read the on-disk label if we are in spoofed-only mode */ if (spoofonly) - return (NULL); + goto done; bp = geteblk((int)lp->d_secsize); bp->b_dev = dev; @@ -178,8 +180,11 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) msg = NULL; #endif - bp->b_flags = B_INVAL | B_AGE | B_READ; - brelse(bp); +done: + if (bp) { + bp->b_flags = B_INVAL | B_AGE | B_READ; + brelse(bp); + } return (msg); } |