]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
gfs2: Sanitize gfs2_meta_check, gfs2_metatype_check, gfs2_io_error
authorAndreas Gruenbacher <agruenba@redhat.com>
Tue, 5 Aug 2025 18:08:35 +0000 (20:08 +0200)
committerAndreas Gruenbacher <agruenba@redhat.com>
Fri, 12 Sep 2025 10:02:15 +0000 (12:02 +0200)
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>
fs/gfs2/util.c
fs/gfs2/util.h

index 020dd21ad51e2bc628617d1d8a2957eadf10370b..56412f63f3bb9b10b7c7b627b5fc5caeaecdacfb 100644 (file)
@@ -471,13 +471,11 @@ void gfs2_consist_rgrpd_i(struct gfs2_rgrpd *rgd,
 
 /*
  * gfs2_meta_check_ii - Flag a magic number consistency error and withdraw
- * Returns: -1 if this call withdrew the machine,
- *          -2 if it was already withdrawn
  */
 
-int gfs2_meta_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
-                      const char *function, char *file,
-                      unsigned int line)
+void gfs2_meta_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
+                       const char *function, char *file,
+                       unsigned int line)
 {
        gfs2_lm(sdp,
                "fatal: invalid metadata block - "
@@ -486,18 +484,15 @@ int gfs2_meta_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
                (unsigned long long)bh->b_blocknr,
                function, file, line);
        gfs2_withdraw(sdp);
-       return -1;
 }
 
 /*
  * gfs2_metatype_check_ii - Flag a metadata type consistency error and withdraw
- * Returns: -1 if this call withdrew the machine,
- *          -2 if it was already withdrawn
  */
 
-int gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
-                          u16 type, u16 t, const char *function,
-                          char *file, unsigned int line)
+void gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
+                           u16 type, u16 t, const char *function,
+                           char *file, unsigned int line)
 {
        gfs2_lm(sdp,
                "fatal: invalid metadata block - "
@@ -506,7 +501,6 @@ int gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
                (unsigned long long)bh->b_blocknr, type, t,
                function, file, line);
        gfs2_withdraw(sdp);
-       return -1;
 }
 
 /*
@@ -515,15 +509,14 @@ int gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
  *          0 if it was already withdrawn
  */
 
-int gfs2_io_error_i(struct gfs2_sbd *sdp, const char *function, char *file,
-                   unsigned int line)
+void gfs2_io_error_i(struct gfs2_sbd *sdp, const char *function, char *file,
+                    unsigned int line)
 {
        gfs2_lm(sdp,
                "fatal: I/O error - "
                "function = %s, file = %s, line = %u\n",
                function, file, line);
        gfs2_withdraw(sdp);
-       return -1;
 }
 
 /*
index 2a8a1fac611afe92770e856f19a348eb1c722c47..da0373b1e82b9e464ced97cab14ce750fd8bc820 100644 (file)
@@ -91,9 +91,9 @@ void gfs2_consist_rgrpd_i(struct gfs2_rgrpd *rgd,
 gfs2_consist_rgrpd_i((rgd), __func__, __FILE__, __LINE__)
 
 
-int gfs2_meta_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
-                      const char *function,
-                      char *file, unsigned int line);
+void gfs2_meta_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
+                       const char *function,
+                       char *file, unsigned int line);
 
 static inline int gfs2_meta_check(struct gfs2_sbd *sdp,
                                    struct buffer_head *bh)
@@ -108,10 +108,10 @@ static inline int gfs2_meta_check(struct gfs2_sbd *sdp,
        return 0;
 }
 
-int gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
-                          u16 type, u16 t,
-                          const char *function,
-                          char *file, unsigned int line);
+void gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
+                           u16 type, u16 t,
+                           const char *function,
+                           char *file, unsigned int line);
 
 static inline int gfs2_metatype_check_i(struct gfs2_sbd *sdp,
                                        struct buffer_head *bh,
@@ -122,12 +122,16 @@ static inline int gfs2_metatype_check_i(struct gfs2_sbd *sdp,
        struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data;
        u32 magic = be32_to_cpu(mh->mh_magic);
        u16 t = be32_to_cpu(mh->mh_type);
-       if (unlikely(magic != GFS2_MAGIC))
-               return gfs2_meta_check_ii(sdp, bh, function,
-                                         file, line);
-        if (unlikely(t != type))
-               return gfs2_metatype_check_ii(sdp, bh, type, t, function,
-                                             file, line);
+       if (unlikely(magic != GFS2_MAGIC)) {
+               gfs2_meta_check_ii(sdp, bh, function,
+                                  file, line);
+               return -EIO;
+       }
+        if (unlikely(t != type)) {
+               gfs2_metatype_check_ii(sdp, bh, type, t, function,
+                                      file, line);
+               return -EIO;
+       }
        return 0;
 }
 
@@ -144,8 +148,8 @@ static inline void gfs2_metatype_set(struct buffer_head *bh, u16 type,
 }
 
 
-int gfs2_io_error_i(struct gfs2_sbd *sdp, const char *function,
-                   char *file, unsigned int line);
+void gfs2_io_error_i(struct gfs2_sbd *sdp, const char *function,
+                    char *file, unsigned int line);
 
 int check_journal_clean(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd,
                        bool verbose);