The branch stable/13 has been updated by mckusick:

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

commit 02966cbdf03ae48a7c79cc75dd25eea9049ccb72
Author:     Kirk McKusick <mckus...@freebsd.org>
AuthorDate: 2021-05-29 02:41:05 +0000
Commit:     Kirk McKusick <mckus...@freebsd.org>
CommitDate: 2021-06-02 19:41:38 +0000

    Fix fsck_ufs segfault when it needs to rerun.
    
    Sponsored by: Netflix
    
    (cherry picked from commit 5c9e9eb7a27feb24136c16706f3db8ce7c8bbc47)
---
 sbin/fsck_ffs/inode.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/sbin/fsck_ffs/inode.c b/sbin/fsck_ffs/inode.c
index d4e5723f559f..ba2d5892238e 100644
--- a/sbin/fsck_ffs/inode.c
+++ b/sbin/fsck_ffs/inode.c
@@ -416,14 +416,14 @@ void
 ginode(ino_t inumber, struct inode *ip)
 {
        ufs2_daddr_t iblk;
-       static ino_t startinum = -1;
 
        if (inumber < UFS_ROOTINO || inumber > maxino)
                errx(EEXIT, "bad inode number %ju to ginode",
                    (uintmax_t)inumber);
        ip->i_number = inumber;
-       if (startinum != -1 &&
-           inumber >= startinum && inumber < startinum + INOPB(&sblock)) {
+       if (icachebp != NULL &&
+           inumber >= icachebp->b_index &&
+           inumber < icachebp->b_index + INOPB(&sblock)) {
                /* take an additional reference for the returned inode */
                icachebp->b_refcnt++;
        } else {
@@ -433,14 +433,14 @@ ginode(ino_t inumber, struct inode *ip)
                        brelse(icachebp);
                icachebp = getdatablk(iblk, sblock.fs_bsize, BT_INODES);
                if (icachebp->b_errs != 0) {
+                       icachebp = NULL;
                        ip->i_bp = NULL;
                        ip->i_dp = &zino;
                        return;
                }
-               startinum = rounddown(inumber, INOPB(&sblock));
                /* take a cache-hold reference on new icachebp */
                icachebp->b_refcnt++;
-               icachebp->b_index = startinum;
+               icachebp->b_index = rounddown(inumber, INOPB(&sblock));
        }
        ip->i_bp = icachebp;
        if (sblock.fs_magic == FS_UFS1_MAGIC) {
_______________________________________________
dev-commits-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all
To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"

Reply via email to