rdma: Fix incorrectly handled NLA validation

mnl_attr_type_valid() receives maximum attribute type, which means that
we were supposed to supply the latest valid netlink attribute and not
the number of attributes. Such coding mistake caused to failures while
NLA attributes were extended.

Fixes: 74bd75c2b6 ("rdma: Add basic infrastructure for RDMA tool")
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
This commit is contained in:
Leon Romanovsky 2018-12-30 15:34:09 +02:00 committed by Stephen Hemminger
parent cb65a9cb81
commit f0cabaca38
1 changed files with 2 additions and 2 deletions

View File

@ -425,8 +425,8 @@ int rd_attr_cb(const struct nlattr *attr, void *data)
const struct nlattr **tb = data;
int type;
if (mnl_attr_type_valid(attr, RDMA_NLDEV_ATTR_MAX) < 0)
/* We received uknown attribute */
if (mnl_attr_type_valid(attr, RDMA_NLDEV_ATTR_MAX - 1) < 0)
/* We received unknown attribute */
return MNL_CB_OK;
type = mnl_attr_get_type(attr);