aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2009-05-19 18:27:55 -0400
committerDavid S. Miller <davem@davemloft.net>2009-05-19 18:36:16 -0400
commitfd2120ca0da9108e53f8db2fe57ab74fca76fd56 (patch)
tree814d647ba22780f741caa119c7c4a81f81bb3695 /net
parente5488ce56995e987a0cf9689e190b712a616a980 (diff)
net: use NLMSG_DEFAULT_SIZE in nlmsg_new() allocations
nlmsg_new() adds the size of the netlink header to the value that has been passed as parameter. If NLMSG_GOODSIZE is selected, we request an allocation of one memory page plus the size of the header. Instead, NLMSG_DEFAULT_SIZE should be used since it already substracts the size of the Netlink header. I have the impression that the similar naming in both constant is error prone when using it with nlmsg_new(). This is already documented in include/net/netlink.h Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/irda/irnetlink.c2
-rw-r--r--net/wireless/nl80211.c32
2 files changed, 17 insertions, 17 deletions
diff --git a/net/irda/irnetlink.c b/net/irda/irnetlink.c
index 2f05ec1037ab..82c6118d82c6 100644
--- a/net/irda/irnetlink.c
+++ b/net/irda/irnetlink.c
@@ -87,7 +87,7 @@ static int irda_nl_get_mode(struct sk_buff *skb, struct genl_info *info)
87 if (!dev) 87 if (!dev)
88 return -ENODEV; 88 return -ENODEV;
89 89
90 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 90 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
91 if (!msg) { 91 if (!msg) {
92 dev_put(dev); 92 dev_put(dev);
93 return -ENOMEM; 93 return -ENOMEM;
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index f0fec2f49828..ade40d503bf0 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -388,7 +388,7 @@ static int nl80211_get_wiphy(struct sk_buff *skb, struct genl_info *info)
388 if (IS_ERR(dev)) 388 if (IS_ERR(dev))
389 return PTR_ERR(dev); 389 return PTR_ERR(dev);
390 390
391 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 391 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
392 if (!msg) 392 if (!msg)
393 goto out_err; 393 goto out_err;
394 394
@@ -716,7 +716,7 @@ static int nl80211_get_interface(struct sk_buff *skb, struct genl_info *info)
716 if (err) 716 if (err)
717 return err; 717 return err;
718 718
719 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 719 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
720 if (!msg) 720 if (!msg)
721 goto out_err; 721 goto out_err;
722 722
@@ -989,7 +989,7 @@ static int nl80211_get_key(struct sk_buff *skb, struct genl_info *info)
989 goto out; 989 goto out;
990 } 990 }
991 991
992 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 992 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
993 if (!msg) { 993 if (!msg) {
994 err = -ENOMEM; 994 err = -ENOMEM;
995 goto out; 995 goto out;
@@ -1600,7 +1600,7 @@ static int nl80211_get_station(struct sk_buff *skb, struct genl_info *info)
1600 if (err) 1600 if (err)
1601 goto out; 1601 goto out;
1602 1602
1603 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 1603 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
1604 if (!msg) 1604 if (!msg)
1605 goto out; 1605 goto out;
1606 1606
@@ -1994,7 +1994,7 @@ static int nl80211_get_mpath(struct sk_buff *skb, struct genl_info *info)
1994 if (err) 1994 if (err)
1995 goto out; 1995 goto out;
1996 1996
1997 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 1997 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
1998 if (!msg) 1998 if (!msg)
1999 goto out; 1999 goto out;
2000 2000
@@ -2310,7 +2310,7 @@ static int nl80211_get_mesh_params(struct sk_buff *skb,
2310 goto out; 2310 goto out;
2311 2311
2312 /* Draw up a netlink message to send back */ 2312 /* Draw up a netlink message to send back */
2313 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 2313 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
2314 if (!msg) { 2314 if (!msg) {
2315 err = -ENOBUFS; 2315 err = -ENOBUFS;
2316 goto out; 2316 goto out;
@@ -2488,7 +2488,7 @@ static int nl80211_get_reg(struct sk_buff *skb, struct genl_info *info)
2488 if (!cfg80211_regdomain) 2488 if (!cfg80211_regdomain)
2489 goto out; 2489 goto out;
2490 2490
2491 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 2491 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
2492 if (!msg) { 2492 if (!msg) {
2493 err = -ENOBUFS; 2493 err = -ENOBUFS;
2494 goto out; 2494 goto out;
@@ -3541,7 +3541,7 @@ void nl80211_notify_dev_rename(struct cfg80211_registered_device *rdev)
3541{ 3541{
3542 struct sk_buff *msg; 3542 struct sk_buff *msg;
3543 3543
3544 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 3544 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
3545 if (!msg) 3545 if (!msg)
3546 return; 3546 return;
3547 3547
@@ -3582,7 +3582,7 @@ void nl80211_send_scan_done(struct cfg80211_registered_device *rdev,
3582{ 3582{
3583 struct sk_buff *msg; 3583 struct sk_buff *msg;
3584 3584
3585 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 3585 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
3586 if (!msg) 3586 if (!msg)
3587 return; 3587 return;
3588 3588
@@ -3600,7 +3600,7 @@ void nl80211_send_scan_aborted(struct cfg80211_registered_device *rdev,
3600{ 3600{
3601 struct sk_buff *msg; 3601 struct sk_buff *msg;
3602 3602
3603 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 3603 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
3604 if (!msg) 3604 if (!msg)
3605 return; 3605 return;
3606 3606
@@ -3622,7 +3622,7 @@ void nl80211_send_reg_change_event(struct regulatory_request *request)
3622 struct sk_buff *msg; 3622 struct sk_buff *msg;
3623 void *hdr; 3623 void *hdr;
3624 3624
3625 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 3625 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
3626 if (!msg) 3626 if (!msg)
3627 return; 3627 return;
3628 3628
@@ -3676,7 +3676,7 @@ static void nl80211_send_mlme_event(struct cfg80211_registered_device *rdev,
3676 struct sk_buff *msg; 3676 struct sk_buff *msg;
3677 void *hdr; 3677 void *hdr;
3678 3678
3679 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC); 3679 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);
3680 if (!msg) 3680 if (!msg)
3681 return; 3681 return;
3682 3682
@@ -3739,7 +3739,7 @@ static void nl80211_send_mlme_timeout(struct cfg80211_registered_device *rdev,
3739 struct sk_buff *msg; 3739 struct sk_buff *msg;
3740 void *hdr; 3740 void *hdr;
3741 3741
3742 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC); 3742 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);
3743 if (!msg) 3743 if (!msg)
3744 return; 3744 return;
3745 3745
@@ -3787,7 +3787,7 @@ void nl80211_send_ibss_bssid(struct cfg80211_registered_device *rdev,
3787 struct sk_buff *msg; 3787 struct sk_buff *msg;
3788 void *hdr; 3788 void *hdr;
3789 3789
3790 msg = nlmsg_new(NLMSG_GOODSIZE, gfp); 3790 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
3791 if (!msg) 3791 if (!msg)
3792 return; 3792 return;
3793 3793
@@ -3822,7 +3822,7 @@ void nl80211_michael_mic_failure(struct cfg80211_registered_device *rdev,
3822 struct sk_buff *msg; 3822 struct sk_buff *msg;
3823 void *hdr; 3823 void *hdr;
3824 3824
3825 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 3825 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
3826 if (!msg) 3826 if (!msg)
3827 return; 3827 return;
3828 3828
@@ -3862,7 +3862,7 @@ void nl80211_send_beacon_hint_event(struct wiphy *wiphy,
3862 void *hdr; 3862 void *hdr;
3863 struct nlattr *nl_freq; 3863 struct nlattr *nl_freq;
3864 3864
3865 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC); 3865 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);
3866 if (!msg) 3866 if (!msg)
3867 return; 3867 return;
3868 3868