On Dec 27, 2012, at 11:46 PM, Taylor R Campbell wrote:
> From: hann...@netbsd.org
> Date: Thu, 20 Dec 2012 08:03:46 +
>
> --- sys/fs/msdosfs/msdosfs_vnops.c 29 Apr 2012 22:53:59 - 1.83
> +++ sys/fs/msdosfs/msdosfs_vnops.c 20 Dec 2012 08:03:42 - 1.84
> @@ -527,7 +527,6 @@ msdosfs_read(void *v)
> NOCRED, 0, &bp);
> n = MIN(n, pmp->pm_bpcluster - bp->b_resid);
> if (error) {
> - brelse(bp, 0);
>
> Looks like you need to move the initialization of n to after the error
> branch.
Fixed, thanks.
> --- sys/ufs/ext2fs/ext2fs_vfsops.c 21 Nov 2012 23:11:23 -
> 1.167
> +++ sys/ufs/ext2fs/ext2fs_vfsops.c 20 Dec 2012 08:03:44 -
> 1.168
> @@ -772,8 +770,8 @@ ext2fs_mountfs(struct vnode *devvp, stru
> return (0);
>
>out:
> - KASSERT(bp != NULL);
> - brelse(bp, 0);
> + if (bp != NULL)
> + brelse(bp, 0);
>
>
> Are bread &c. supposed to guarantee that bp is null on error, or are
> they supposed to leave it in an undefined state? Either way, it seems
> to me that the intent ought to be documented in buffercache(9).
Both bread() and breadn() will either return with `error == 0, *bpp != NULL'
or `error != 0, *bpp == NULL'.
--
J. Hannken-Illjes - hann...@eis.cs.tu-bs.de - TU Braunschweig (Germany)