]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
hpfs: hpfs_error: Remove static buffer, use vsprintf extension %pV instead
authorJoe Perches <joe@perches.com>
Fri, 27 Mar 2015 03:47:10 +0000 (20:47 -0700)
committerZefan Li <lizefan@huawei.com>
Mon, 21 Mar 2016 01:17:41 +0000 (09:17 +0800)
commit a28e4b2b18ccb90df402da3f21e1a83c9d4f8ec1 upstream.

Removing unnecessary static buffers is good.
Use the vsprintf %pV extension instead.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Mikulas Patocka <mikulas@twibright.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[Mikulas:
 - The bug corrected by the patch is - if hpfs_error is called concurrently
   on multiple filesystems, it could corrupt the string because the text
   buffer is shared. That's why I marked the patch for stable.]
[lizf: Backported to 3.4: adjust context]
Signed-off-by: Zefan Li <lizefan@huawei.com>
fs/hpfs/super.c

index 0b990b288aff935ba6a8056634d023507ca67fb8..efc18237fbaec763d24eea3f8847a868d6feaa01 100644 (file)
@@ -52,17 +52,20 @@ static void unmark_dirty(struct super_block *s)
 }
 
 /* Filesystem error... */
-static char err_buf[1024];
-
 void hpfs_error(struct super_block *s, const char *fmt, ...)
 {
+       struct va_format vaf;
        va_list args;
 
        va_start(args, fmt);
-       vsnprintf(err_buf, sizeof(err_buf), fmt, args);
+
+       vaf.fmt = fmt;
+       vaf.va = &args;
+
+       pr_err("filesystem error: %pV", &vaf);
+
        va_end(args);
 
-       printk("HPFS: filesystem error: %s", err_buf);
        if (!hpfs_sb(s)->sb_was_error) {
                if (hpfs_sb(s)->sb_err == 2) {
                        printk("; crashing the system because you wanted it\n");