brcompat: Check for null pointer before reading netlink attribute.
authorBen Pfaff <blp@nicira.com>
Thu, 23 Apr 2009 18:23:43 +0000 (11:23 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 24 Apr 2009 18:09:56 +0000 (11:09 -0700)
Netlink policy parsing only checks that, if an attribute is present, then
its format is correct.  It doesn't ensure that attributes are present, so
an explicit check is needed, which this commit adds.

datapath/brcompat.c

index e20af016c8ff4e6f265f5c87388fb187806e747d..46ecce005663d481e59238b96aaa65fc440bbfc5 100644 (file)
@@ -294,6 +294,9 @@ static struct nla_policy brc_genl_policy[BRC_GENL_A_MAX + 1] = {
 static int
 brc_genl_dp_result(struct sk_buff *skb, struct genl_info *info)
 {
+       if (!info->attrs[BRC_GENL_A_ERR_CODE])
+               return -EINVAL;
+       
        dp_act_err = nla_get_u32(info->attrs[BRC_GENL_A_ERR_CODE]);
        complete(&dp_act_done);