The branch main has been updated by emaste:

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

commit bc33c99234a676c41cde63cce389dd6b8b70adfc
Author:     Ed Maste <ema...@freebsd.org>
AuthorDate: 2023-03-13 20:51:51 +0000
Commit:     Ed Maste <ema...@freebsd.org>
CommitDate: 2023-03-14 02:39:09 +0000

    makefs: do not call brelse if bread returns an error
    
    If bread returns an error there is no bp to brelse.  One of these
    changes was taken from NetBSD commit 0a62dad69f62 ("This works well
    enough to populate..."), the rest were found by looking for the same
    pattern.
    
    Reviewed by:    imp
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D39069
---
 usr.sbin/makefs/ffs/ffs_alloc.c        | 2 --
 usr.sbin/makefs/msdos/msdosfs_lookup.c | 4 ----
 2 files changed, 6 deletions(-)

diff --git a/usr.sbin/makefs/ffs/ffs_alloc.c b/usr.sbin/makefs/ffs/ffs_alloc.c
index ff0e72c56af0..4dee635fba96 100644
--- a/usr.sbin/makefs/ffs/ffs_alloc.c
+++ b/usr.sbin/makefs/ffs/ffs_alloc.c
@@ -305,7 +305,6 @@ ffs_alloccg(struct inode *ip, int cg, daddr_t bpref, int 
size)
        error = bread((void *)ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)),
            (int)fs->fs_cgsize, NULL, &bp);
        if (error) {
-               brelse(bp);
                return (0);
        }
        cgp = (struct cg *)bp->b_data;
@@ -449,7 +448,6 @@ ffs_blkfree(struct inode *ip, daddr_t bno, long size)
        error = bread((void *)ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)),
            (int)fs->fs_cgsize, NULL, &bp);
        if (error) {
-               brelse(bp);
                return;
        }
        cgp = (struct cg *)bp->b_data;
diff --git a/usr.sbin/makefs/msdos/msdosfs_lookup.c 
b/usr.sbin/makefs/msdos/msdosfs_lookup.c
index fb2f4deceaf2..68fee52cdd88 100644
--- a/usr.sbin/makefs/msdos/msdosfs_lookup.c
+++ b/usr.sbin/makefs/msdos/msdosfs_lookup.c
@@ -125,7 +125,6 @@ createde(struct denode *dep, struct denode *ddep, struct 
denode **depp,
                diroffset &= pmp->pm_crbomask;
        if ((error = bread((void *)pmp->pm_devvp, bn, blsize, NOCRED,
            &bp)) != 0) {
-               brelse(bp);
                return error;
        }
        ndep = bptoep(pmp, bp, ddep->de_fndoffset);
@@ -157,7 +156,6 @@ createde(struct denode *dep, struct denode *ddep, struct 
denode **depp,
                                error = bread((void *)pmp->pm_devvp, bn, blsize,
                                              NOCRED, &bp);
                                if (error) {
-                                       brelse(bp);
                                        return error;
                                }
                                ndep = bptoep(pmp, bp, ddep->de_fndoffset);
@@ -213,7 +211,6 @@ m_readep(struct msdosfsmount *pmp, u_long dirclust, u_long 
diroffset,
        bn = detobn(pmp, dirclust, diroffset);
        if ((error = bread((void *)pmp->pm_devvp, bn, blsize, NOCRED,
            bpp)) != 0) {
-               brelse(*bpp);
                *bpp = NULL;
                return (error);
        }
@@ -274,7 +271,6 @@ uniqdosname(struct denode *dep, struct componentname *cnp, 
u_char *cp)
                        error = bread((void *)pmp->pm_devvp, bn, blsize,
                            NOCRED, &bp);
                        if (error) {
-                               brelse(bp);
                                return error;
                        }
                        for (dentp = (struct direntry *)bp->b_data;

Reply via email to