From e910d98670345061efaf7992a00dc8991ea0146e Mon Sep 17 00:00:00 2001 From: Eivind Eklund Date: Wed, 16 Dec 1998 00:10:51 +0000 Subject: [PATCH] Fix possible NULL-pointer deref in error case (same as DEVFS). --- sys/fs/specfs/spec_vnops.c | 4 ++-- sys/miscfs/specfs/spec_vnops.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/fs/specfs/spec_vnops.c b/sys/fs/specfs/spec_vnops.c index f0914c3e2709..ff0f347546b7 100644 --- a/sys/fs/specfs/spec_vnops.c +++ b/sys/fs/specfs/spec_vnops.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)spec_vnops.c 8.14 (Berkeley) 5/21/95 - * $Id: spec_vnops.c,v 1.76 1998/10/31 15:31:24 peter Exp $ + * $Id: spec_vnops.c,v 1.77 1998/12/07 21:58:33 archie Exp $ */ #include @@ -379,11 +379,11 @@ spec_write(ap) bp = getblk(vp, bn, bsize, 0, 0); else error = bread(vp, bn, bsize, NOCRED, &bp); - n = min(n, bsize - bp->b_resid); if (error) { brelse(bp); return (error); } + n = min(n, bsize - bp->b_resid); error = uiomove((char *)bp->b_data + on, n, uio); if (n + on == bsize) bawrite(bp); diff --git a/sys/miscfs/specfs/spec_vnops.c b/sys/miscfs/specfs/spec_vnops.c index f0914c3e2709..ff0f347546b7 100644 --- a/sys/miscfs/specfs/spec_vnops.c +++ b/sys/miscfs/specfs/spec_vnops.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)spec_vnops.c 8.14 (Berkeley) 5/21/95 - * $Id: spec_vnops.c,v 1.76 1998/10/31 15:31:24 peter Exp $ + * $Id: spec_vnops.c,v 1.77 1998/12/07 21:58:33 archie Exp $ */ #include @@ -379,11 +379,11 @@ spec_write(ap) bp = getblk(vp, bn, bsize, 0, 0); else error = bread(vp, bn, bsize, NOCRED, &bp); - n = min(n, bsize - bp->b_resid); if (error) { brelse(bp); return (error); } + n = min(n, bsize - bp->b_resid); error = uiomove((char *)bp->b_data + on, n, uio); if (n + on == bsize) bawrite(bp);