diff options
author | Thomas Graf <tgraf@suug.ch> | 2008-05-22 13:48:59 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-05-22 13:48:59 -0400 |
commit | b9a2f2e450b0f770bb4347ae8d48eb2dea701e24 (patch) | |
tree | 7f2d25b44259bdeb8dd35448bbf16f68aa1d5dd2 /include/net | |
parent | 071f92d05967a0c8422f1c8587ce0b4d90a8b447 (diff) |
netlink: Fix nla_parse_nested_compat() to call nla_parse() directly
The purpose of nla_parse_nested_compat() is to parse attributes which
contain a struct followed by a stream of nested attributes. So far,
it called nla_parse_nested() to parse the stream of nested attributes
which was wrong, as nla_parse_nested() expects a container attribute
as data which holds the attribute stream. It needs to call
nla_parse() directly while pointing at the next possible alignment
point after the struct in the beginning of the attribute.
With this patch, I can no longer reproduce the reported leftover
warnings.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Acked-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r-- | include/net/netlink.h | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/include/net/netlink.h b/include/net/netlink.h index a5506c42f03c..112dcdf7e34e 100644 --- a/include/net/netlink.h +++ b/include/net/netlink.h | |||
@@ -772,12 +772,13 @@ static inline int __nla_parse_nested_compat(struct nlattr *tb[], int maxtype, | |||
772 | const struct nla_policy *policy, | 772 | const struct nla_policy *policy, |
773 | int len) | 773 | int len) |
774 | { | 774 | { |
775 | if (nla_len(nla) < len) | 775 | int nested_len = nla_len(nla) - NLA_ALIGN(len); |
776 | |||
777 | if (nested_len < 0) | ||
776 | return -1; | 778 | return -1; |
777 | if (nla_len(nla) >= NLA_ALIGN(len) + sizeof(struct nlattr)) | 779 | if (nested_len >= nla_attr_size(0)) |
778 | return nla_parse_nested(tb, maxtype, | 780 | return nla_parse(tb, maxtype, nla_data(nla) + NLA_ALIGN(len), |
779 | nla_data(nla) + NLA_ALIGN(len), | 781 | nested_len, policy); |
780 | policy); | ||
781 | memset(tb, 0, sizeof(struct nlattr *) * (maxtype + 1)); | 782 | memset(tb, 0, sizeof(struct nlattr *) * (maxtype + 1)); |
782 | return 0; | 783 | return 0; |
783 | } | 784 | } |