Skip to content

Commit 055adcb

Browse files
JoePerchesjankara
authored andcommitted
quota: Use %pV and __attribute__((format (printf in __quota_error and fix fallout
Use %pV in __quota_error so a single printk can not be interleaved with other logging messages. Add __attribute__((format (printf, 3, 4))) so format and arguments can be verified by compiler. Make sure printk formats and arguments match. Block # needed a pointer dereference. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Jan Kara <jack@suse.cz>
1 parent 9c52749 commit 055adcb

3 files changed

Lines changed: 19 additions & 13 deletions

File tree

‎fs/quota/dquot.c‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,20 @@ __cacheline_aligned_in_smp DEFINE_SPINLOCK(dq_data_lock);
133133
EXPORT_SYMBOL(dq_data_lock);
134134

135135
void __quota_error(struct super_block *sb, const char *func,
136-
const char *fmt, ...)
136+
const char *fmt, ...)
137137
{
138-
va_list args;
139-
140138
if (printk_ratelimit()) {
139+
va_list args;
140+
struct va_format vaf;
141+
141142
va_start(args, fmt);
142-
printk(KERN_ERR "Quota error (device %s): %s: ",
143-
sb->s_id, func);
144-
vprintk(fmt, args);
145-
printk("\n");
143+
144+
vaf.fmt = fmt;
145+
vaf.va = &args;
146+
147+
printk(KERN_ERR "Quota error (device %s): %s: %pV\n",
148+
sb->s_id, func, &vaf);
149+
146150
va_end(args);
147151
}
148152
}

‎fs/quota/quota_tree.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,8 @@ static int remove_tree(struct qtree_mem_dqinfo *info, struct dquot *dquot,
468468
return -ENOMEM;
469469
ret = read_blk(info, *blk, buf);
470470
if (ret < 0) {
471-
quota_error(dquot->dq_sb, "Can't read quota data "
472-
"block %u", blk);
471+
quota_error(dquot->dq_sb, "Can't read quota data block %u",
472+
*blk);
473473
goto out_buf;
474474
}
475475
newblk = le32_to_cpu(ref[get_index(info, dquot->dq_id, depth)]);
@@ -493,8 +493,9 @@ static int remove_tree(struct qtree_mem_dqinfo *info, struct dquot *dquot,
493493
} else {
494494
ret = write_blk(info, *blk, buf);
495495
if (ret < 0)
496-
quota_error(dquot->dq_sb, "Can't write quota "
497-
"tree block %u", blk);
496+
quota_error(dquot->dq_sb,
497+
"Can't write quota tree block %u",
498+
*blk);
498499
}
499500
}
500501
out_buf:

‎include/linux/quotaops.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ static inline bool is_quota_modification(struct inode *inode, struct iattr *ia)
3131
#define quota_error(sb, fmt, args...) \
3232
__quota_error((sb), __func__, fmt , ## args)
3333

34-
extern void __quota_error(struct super_block *sb, const char *func,
35-
const char *fmt, ...);
34+
extern __attribute__((format (printf, 3, 4)))
35+
void __quota_error(struct super_block *sb, const char *func,
36+
const char *fmt, ...);
3637

3738
/*
3839
* declaration of quota_function calls in kernel.

0 commit comments

Comments
 (0)