]> git.baikalelectronics.ru Git - kernel.git/commitdiff
netlink: make validation_data const
authorJohannes Berg <johannes.berg@intel.com>
Wed, 26 Sep 2018 09:15:31 +0000 (11:15 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 28 Sep 2018 17:24:39 +0000 (10:24 -0700)
The validation data is only used within the policy that
should usually already be const, and isn't changed in any
code that uses it. Therefore, make the validation_data
pointer const.

While at it, remove the duplicate variable in the bitfield
validation that I'd otherwise have to change to const.

Reviewed-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/netlink.h
lib/nlattr.c

index b680fe365e9125e5dd13eabcee475268ffbeed9c..0d698215d4d9d8ddd3d4bb1b1d1c78734a22f6c2 100644 (file)
@@ -237,7 +237,7 @@ enum {
 struct nla_policy {
        u16             type;
        u16             len;
-       void            *validation_data;
+       const void     *validation_data;
 };
 
 #define NLA_POLICY_EXACT_LEN(_len)     { .type = NLA_EXACT_LEN, .len = _len }
index 120ad569e13da7bf21063d464cc993c2365c1b32..e2e5b38394d51c4cd10a2ce288f91c438774d1a8 100644 (file)
@@ -45,12 +45,11 @@ static const u8 nla_attr_minlen[NLA_TYPE_MAX+1] = {
 };
 
 static int validate_nla_bitfield32(const struct nlattr *nla,
-                                  u32 *valid_flags_allowed)
+                                  const u32 *valid_flags_mask)
 {
        const struct nla_bitfield32 *bf = nla_data(nla);
-       u32 *valid_flags_mask = valid_flags_allowed;
 
-       if (!valid_flags_allowed)
+       if (!valid_flags_mask)
                return -EINVAL;
 
        /*disallow invalid bit selector */