diff --git a/include/net/netlink.h b/include/net/netlink.h
index dd657a33f8c304455c99d83121fc743a86d13973..d3938f11ae52ee234ea0b4c4e3f7b2e37615601d 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -698,7 +698,8 @@ static inline int nla_len(const struct nlattr *nla)
  */
 static inline int nla_ok(const struct nlattr *nla, int remaining)
 {
-	return nla->nla_len >= sizeof(*nla) &&
+	return remaining >= (int) sizeof(*nla) &&
+	       nla->nla_len >= sizeof(*nla) &&
 	       nla->nla_len <= remaining;
 }