Skip to content

Commit 13c0004

Browse files
author
Andreas Gruenbacher
committed
gfs2: Sanitize gfs2_meta_check, gfs2_metatype_check, gfs2_io_error
Change those functions to either return a useful value, or nothing at all. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Reviewed-by: Andrew Price <anprice@redhat.com>
1 parent 6e42240 commit 13c0004

2 files changed

Lines changed: 27 additions & 30 deletions

File tree

fs/gfs2/util.c

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -471,13 +471,11 @@ void gfs2_consist_rgrpd_i(struct gfs2_rgrpd *rgd,
471471

472472
/*
473473
* gfs2_meta_check_ii - Flag a magic number consistency error and withdraw
474-
* Returns: -1 if this call withdrew the machine,
475-
* -2 if it was already withdrawn
476474
*/
477475

478-
int gfs2_meta_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
479-
const char *function, char *file,
480-
unsigned int line)
476+
void gfs2_meta_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
477+
const char *function, char *file,
478+
unsigned int line)
481479
{
482480
gfs2_lm(sdp,
483481
"fatal: invalid metadata block - "
@@ -486,18 +484,15 @@ int gfs2_meta_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
486484
(unsigned long long)bh->b_blocknr,
487485
function, file, line);
488486
gfs2_withdraw(sdp);
489-
return -1;
490487
}
491488

492489
/*
493490
* gfs2_metatype_check_ii - Flag a metadata type consistency error and withdraw
494-
* Returns: -1 if this call withdrew the machine,
495-
* -2 if it was already withdrawn
496491
*/
497492

498-
int gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
499-
u16 type, u16 t, const char *function,
500-
char *file, unsigned int line)
493+
void gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
494+
u16 type, u16 t, const char *function,
495+
char *file, unsigned int line)
501496
{
502497
gfs2_lm(sdp,
503498
"fatal: invalid metadata block - "
@@ -506,7 +501,6 @@ int gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
506501
(unsigned long long)bh->b_blocknr, type, t,
507502
function, file, line);
508503
gfs2_withdraw(sdp);
509-
return -1;
510504
}
511505

512506
/*
@@ -515,15 +509,14 @@ int gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
515509
* 0 if it was already withdrawn
516510
*/
517511

518-
int gfs2_io_error_i(struct gfs2_sbd *sdp, const char *function, char *file,
519-
unsigned int line)
512+
void gfs2_io_error_i(struct gfs2_sbd *sdp, const char *function, char *file,
513+
unsigned int line)
520514
{
521515
gfs2_lm(sdp,
522516
"fatal: I/O error - "
523517
"function = %s, file = %s, line = %u\n",
524518
function, file, line);
525519
gfs2_withdraw(sdp);
526-
return -1;
527520
}
528521

529522
/*

fs/gfs2/util.h

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ void gfs2_consist_rgrpd_i(struct gfs2_rgrpd *rgd,
9191
gfs2_consist_rgrpd_i((rgd), __func__, __FILE__, __LINE__)
9292

9393

94-
int gfs2_meta_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
95-
const char *function,
96-
char *file, unsigned int line);
94+
void gfs2_meta_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
95+
const char *function,
96+
char *file, unsigned int line);
9797

9898
static inline int gfs2_meta_check(struct gfs2_sbd *sdp,
9999
struct buffer_head *bh)
@@ -108,10 +108,10 @@ static inline int gfs2_meta_check(struct gfs2_sbd *sdp,
108108
return 0;
109109
}
110110

111-
int gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
112-
u16 type, u16 t,
113-
const char *function,
114-
char *file, unsigned int line);
111+
void gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
112+
u16 type, u16 t,
113+
const char *function,
114+
char *file, unsigned int line);
115115

116116
static inline int gfs2_metatype_check_i(struct gfs2_sbd *sdp,
117117
struct buffer_head *bh,
@@ -122,12 +122,16 @@ static inline int gfs2_metatype_check_i(struct gfs2_sbd *sdp,
122122
struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data;
123123
u32 magic = be32_to_cpu(mh->mh_magic);
124124
u16 t = be32_to_cpu(mh->mh_type);
125-
if (unlikely(magic != GFS2_MAGIC))
126-
return gfs2_meta_check_ii(sdp, bh, function,
127-
file, line);
128-
if (unlikely(t != type))
129-
return gfs2_metatype_check_ii(sdp, bh, type, t, function,
130-
file, line);
125+
if (unlikely(magic != GFS2_MAGIC)) {
126+
gfs2_meta_check_ii(sdp, bh, function,
127+
file, line);
128+
return -EIO;
129+
}
130+
if (unlikely(t != type)) {
131+
gfs2_metatype_check_ii(sdp, bh, type, t, function,
132+
file, line);
133+
return -EIO;
134+
}
131135
return 0;
132136
}
133137

@@ -144,8 +148,8 @@ static inline void gfs2_metatype_set(struct buffer_head *bh, u16 type,
144148
}
145149

146150

147-
int gfs2_io_error_i(struct gfs2_sbd *sdp, const char *function,
148-
char *file, unsigned int line);
151+
void gfs2_io_error_i(struct gfs2_sbd *sdp, const char *function,
152+
char *file, unsigned int line);
149153

150154
int check_journal_clean(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd,
151155
bool verbose);

0 commit comments

Comments
 (0)