Skip to content

Commit 22dd483

Browse files
jankaraLinus Torvalds
authored andcommitted
Fix computation of SKB size for quota messages
Fix computation of size of skb needed for quota message. We should use netlink provided functions and not just an ad-hoc number. Also don't print the return value from nla_put_foo() as it is always -1. Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent b886290 commit 22dd483

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

‎fs/dquot.c‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -895,9 +895,6 @@ static void print_warning(struct dquot *dquot, const char warntype)
895895

896896
#ifdef CONFIG_QUOTA_NETLINK_INTERFACE
897897

898-
/* Size of quota netlink message - actually an upperbound for buffer size */
899-
#define QUOTA_NL_MSG_SIZE 32
900-
901898
/* Netlink family structure for quota */
902899
static struct genl_family quota_genl_family = {
903900
.id = GENL_ID_GENERATE,
@@ -914,11 +911,13 @@ static void send_warning(const struct dquot *dquot, const char warntype)
914911
struct sk_buff *skb;
915912
void *msg_head;
916913
int ret;
914+
int msg_size = 4 * nla_total_size(sizeof(u32)) +
915+
2 * nla_total_size(sizeof(u64));
917916

918917
/* We have to allocate using GFP_NOFS as we are called from a
919918
* filesystem performing write and thus further recursion into
920919
* the fs to free some data could cause deadlocks. */
921-
skb = genlmsg_new(QUOTA_NL_MSG_SIZE, GFP_NOFS);
920+
skb = genlmsg_new(msg_size, GFP_NOFS);
922921
if (!skb) {
923922
printk(KERN_ERR
924923
"VFS: Not enough memory to send quota warning.\n");
@@ -959,7 +958,7 @@ static void send_warning(const struct dquot *dquot, const char warntype)
959958
"VFS: Failed to send notification message: %d\n", ret);
960959
return;
961960
attr_err_out:
962-
printk(KERN_ERR "VFS: Failed to compose quota message: %d\n", ret);
961+
printk(KERN_ERR "VFS: Not enough space to compose quota message!\n");
963962
err_out:
964963
kfree_skb(skb);
965964
}

0 commit comments

Comments
 (0)