Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/makefs/ffs Don't brelse() if bread() fails. The ker...



details:   https://anonhg.NetBSD.org/src/rev/499b9a5acfab
branches:  trunk
changeset: 373885:499b9a5acfab
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Mar 13 22:17:24 2023 +0000

description:
Don't brelse() if bread() fails. The kernel does this for us. Our bread()
implementation just exits on failure, but if it didn't we would double-free.
>From Ed Maste (https://reviews.freebsd.org/D39069)

diffstat:

 usr.sbin/makefs/ffs/ffs_alloc.c  |   5 ++---
 usr.sbin/makefs/ffs/ffs_balloc.c |  13 +++----------
 2 files changed, 5 insertions(+), 13 deletions(-)

diffs (102 lines):

diff -r a806d83de94b -r 499b9a5acfab usr.sbin/makefs/ffs/ffs_alloc.c
--- a/usr.sbin/makefs/ffs/ffs_alloc.c   Mon Mar 13 22:10:30 2023 +0000
+++ b/usr.sbin/makefs/ffs/ffs_alloc.c   Mon Mar 13 22:17:24 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ffs_alloc.c,v 1.31 2023/01/07 19:41:30 chs Exp $       */
+/*     $NetBSD: ffs_alloc.c,v 1.32 2023/03/13 22:17:24 christos Exp $  */
 /* From: NetBSD: ffs_alloc.c,v 1.50 2001/09/06 02:16:01 lukem Exp */
 
 /*
@@ -47,7 +47,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: ffs_alloc.c,v 1.31 2023/01/07 19:41:30 chs Exp $");
+__RCSID("$NetBSD: ffs_alloc.c,v 1.32 2023/03/13 22:17:24 christos Exp $");
 #endif /* !__lint */
 
 #include <sys/param.h>
@@ -453,7 +453,6 @@
        error = bread(ip->i_devvp, FFS_FSBTODB(fs, cgtod(fs, cg)),
            (int)fs->fs_cgsize, 0, &bp);
        if (error) {
-               brelse(bp, 0);
                return;
        }
        cgp = (struct cg *)bp->b_data;
diff -r a806d83de94b -r 499b9a5acfab usr.sbin/makefs/ffs/ffs_balloc.c
--- a/usr.sbin/makefs/ffs/ffs_balloc.c  Mon Mar 13 22:10:30 2023 +0000
+++ b/usr.sbin/makefs/ffs/ffs_balloc.c  Mon Mar 13 22:17:24 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ffs_balloc.c,v 1.22 2022/11/17 06:40:41 chs Exp $      */
+/*     $NetBSD: ffs_balloc.c,v 1.23 2023/03/13 22:17:24 christos Exp $ */
 /* From NetBSD: ffs_balloc.c,v 1.25 2001/08/08 08:36:36 lukem Exp */
 
 /*
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: ffs_balloc.c,v 1.22 2022/11/17 06:40:41 chs Exp $");
+__RCSID("$NetBSD: ffs_balloc.c,v 1.23 2023/03/13 22:17:24 christos Exp $");
 #endif /* !__lint */
 
 #include <sys/param.h>
@@ -142,7 +142,6 @@
                                error = bread(ip->i_devvp, lbn, fs->fs_bsize,
                                    0, bpp);
                                if (error) {
-                                       brelse(*bpp, 0);
                                        return (error);
                                }
                        }
@@ -168,8 +167,7 @@
                                        error = bread(ip->i_devvp, lbn, osize,
                                            0, bpp);
                                        if (error) {
-                                               brelse(*bpp, 0);
-                                               return (error);
+                                               return error;
                                        }
                                }
                                return 0;
@@ -254,7 +252,6 @@
                error = bread(ip->i_devvp, indirs[i].in_lbn, fs->fs_bsize,
                    0, &bp);
                if (error) {
-                       brelse(bp, 0);
                        return error;
                }
                bap = (int32_t *)bp->b_data;
@@ -324,7 +321,6 @@
        if (bpp != NULL) {
                error = bread(ip->i_devvp, lbn, (int)fs->fs_bsize, 0, &nbp);
                if (error) {
-                       brelse(nbp, 0);
                        return error;
                }
                *bpp = nbp;
@@ -392,7 +388,6 @@
                                error = bread(ip->i_devvp, lbn, fs->fs_bsize,
                                    0, bpp);
                                if (error) {
-                                       brelse(*bpp, 0);
                                        return (error);
                                }
                        }
@@ -418,7 +413,6 @@
                                        error = bread(ip->i_devvp, lbn, osize,
                                            0, bpp);
                                        if (error) {
-                                               brelse(*bpp, 0);
                                                return (error);
                                        }
                                }
@@ -504,7 +498,6 @@
                error = bread(ip->i_devvp, indirs[i].in_lbn, fs->fs_bsize,
                    0, &bp);
                if (error) {
-                       brelse(bp, 0);
                        return error;
                }
                bap = (int64_t *)bp->b_data;



Home | Main Index | Thread Index | Old Index