Commit 22dd4837 authored by Jan Kara's avatar Jan Kara Committed by Linus Torvalds

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: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent b8862906
...@@ -895,9 +895,6 @@ static void print_warning(struct dquot *dquot, const char warntype) ...@@ -895,9 +895,6 @@ static void print_warning(struct dquot *dquot, const char warntype)
#ifdef CONFIG_QUOTA_NETLINK_INTERFACE #ifdef CONFIG_QUOTA_NETLINK_INTERFACE
/* Size of quota netlink message - actually an upperbound for buffer size */
#define QUOTA_NL_MSG_SIZE 32
/* Netlink family structure for quota */ /* Netlink family structure for quota */
static struct genl_family quota_genl_family = { static struct genl_family quota_genl_family = {
.id = GENL_ID_GENERATE, .id = GENL_ID_GENERATE,
...@@ -914,11 +911,13 @@ static void send_warning(const struct dquot *dquot, const char warntype) ...@@ -914,11 +911,13 @@ static void send_warning(const struct dquot *dquot, const char warntype)
struct sk_buff *skb; struct sk_buff *skb;
void *msg_head; void *msg_head;
int ret; int ret;
int msg_size = 4 * nla_total_size(sizeof(u32)) +
2 * nla_total_size(sizeof(u64));
/* We have to allocate using GFP_NOFS as we are called from a /* We have to allocate using GFP_NOFS as we are called from a
* filesystem performing write and thus further recursion into * filesystem performing write and thus further recursion into
* the fs to free some data could cause deadlocks. */ * the fs to free some data could cause deadlocks. */
skb = genlmsg_new(QUOTA_NL_MSG_SIZE, GFP_NOFS); skb = genlmsg_new(msg_size, GFP_NOFS);
if (!skb) { if (!skb) {
printk(KERN_ERR printk(KERN_ERR
"VFS: Not enough memory to send quota warning.\n"); "VFS: Not enough memory to send quota warning.\n");
...@@ -959,7 +958,7 @@ static void send_warning(const struct dquot *dquot, const char warntype) ...@@ -959,7 +958,7 @@ static void send_warning(const struct dquot *dquot, const char warntype)
"VFS: Failed to send notification message: %d\n", ret); "VFS: Failed to send notification message: %d\n", ret);
return; return;
attr_err_out: attr_err_out:
printk(KERN_ERR "VFS: Failed to compose quota message: %d\n", ret); printk(KERN_ERR "VFS: Not enough space to compose quota message!\n");
err_out: err_out:
kfree_skb(skb); kfree_skb(skb);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment