Skip to content

Commit 5131652

Browse files
author
Andreas Gruenbacher
committed
gfs2: Minor gfs2_quota_init error path cleanup
Add a fail_brelse label and use it where useful. Move variable bh out of the loop to extend its visibility to the new label. No functional change. Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent 713f883 commit 5131652

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

fs/gfs2/quota.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,6 +1407,7 @@ int gfs2_quota_init(struct gfs2_sbd *sdp)
14071407
unsigned int found = 0;
14081408
unsigned int hash;
14091409
unsigned int bm_size;
1410+
struct buffer_head *bh;
14101411
u64 dblock;
14111412
u32 extlen = 0;
14121413
int error;
@@ -1426,7 +1427,6 @@ int gfs2_quota_init(struct gfs2_sbd *sdp)
14261427
return error;
14271428

14281429
for (x = 0; x < blocks; x++) {
1429-
struct buffer_head *bh;
14301430
const struct gfs2_quota_change *qc;
14311431
unsigned int y;
14321432

@@ -1440,10 +1440,8 @@ int gfs2_quota_init(struct gfs2_sbd *sdp)
14401440
bh = gfs2_meta_ra(ip->i_gl, dblock, extlen);
14411441
if (!bh)
14421442
goto fail;
1443-
if (gfs2_metatype_check(sdp, bh, GFS2_METATYPE_QC)) {
1444-
brelse(bh);
1445-
goto fail;
1446-
}
1443+
if (gfs2_metatype_check(sdp, bh, GFS2_METATYPE_QC))
1444+
goto fail_brelse;
14471445

14481446
qc = (const struct gfs2_quota_change *)(bh->b_data + sizeof(struct gfs2_meta_header));
14491447
for (y = 0; y < sdp->sd_qc_per_block && slot < sdp->sd_quota_slots;
@@ -1461,10 +1459,8 @@ int gfs2_quota_init(struct gfs2_sbd *sdp)
14611459

14621460
hash = gfs2_qd_hash(sdp, qc_id);
14631461
qd = qd_alloc(hash, sdp, qc_id);
1464-
if (qd == NULL) {
1465-
brelse(bh);
1466-
goto fail;
1467-
}
1462+
if (qd == NULL)
1463+
goto fail_brelse;
14681464

14691465
set_bit(QDF_CHANGE, &qd->qd_flags);
14701466
qd->qd_change = qc_change;
@@ -1494,6 +1490,8 @@ int gfs2_quota_init(struct gfs2_sbd *sdp)
14941490

14951491
return 0;
14961492

1493+
fail_brelse:
1494+
brelse(bh);
14971495
fail:
14981496
gfs2_quota_cleanup(sdp);
14991497
return error;

0 commit comments

Comments
 (0)