Skip to content

Commit 428f651

Browse files
AstralBobAndreas Gruenbacher
authored andcommitted
gfs2: assign rgrp glock before compute_bitstructs
Before this patch, function read_rindex_entry called compute_bitstructs before it allocated a glock for the rgrp. But if compute_bitstructs found a problem with the rgrp, it called gfs2_consist_rgrpd, and that called gfs2_dump_glock for rgd->rd_gl which had not yet been assigned. read_rindex_entry compute_bitstructs gfs2_consist_rgrpd gfs2_dump_glock <---------rgd->rd_gl was not set. This patch changes read_rindex_entry so it assigns an rgrp glock before calling compute_bitstructs so gfs2_dump_glock does not reference an unassigned pointer. If an error is discovered, the glock must also be put, so a new goto and label were added. Reported-by: syzbot+c6fd14145e2f62ca0784@syzkaller.appspotmail.com Signed-off-by: Bob Peterson <rpeterso@redhat.com> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
1 parent 754e0b0 commit 428f651

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

fs/gfs2/rgrp.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -922,15 +922,15 @@ static int read_rindex_entry(struct gfs2_inode *ip)
922922
spin_lock_init(&rgd->rd_rsspin);
923923
mutex_init(&rgd->rd_mutex);
924924

925-
error = compute_bitstructs(rgd);
926-
if (error)
927-
goto fail;
928-
929925
error = gfs2_glock_get(sdp, rgd->rd_addr,
930926
&gfs2_rgrp_glops, CREATE, &rgd->rd_gl);
931927
if (error)
932928
goto fail;
933929

930+
error = compute_bitstructs(rgd);
931+
if (error)
932+
goto fail_glock;
933+
934934
rgd->rd_rgl = (struct gfs2_rgrp_lvb *)rgd->rd_gl->gl_lksb.sb_lvbptr;
935935
rgd->rd_flags &= ~GFS2_RDF_PREFERRED;
936936
if (rgd->rd_data > sdp->sd_max_rg_data)
@@ -944,6 +944,7 @@ static int read_rindex_entry(struct gfs2_inode *ip)
944944
}
945945

946946
error = 0; /* someone else read in the rgrp; free it and ignore it */
947+
fail_glock:
947948
gfs2_glock_put(rgd->rd_gl);
948949

949950
fail:

0 commit comments

Comments
 (0)