Skip to contentSkip to conversation

fix nla_policy_len to actually _iterate_ over the policy

PATCH Applied Lars Ellenberg 3 participants 3 messages Feb 28, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix nla_policy_len to actually _iterate_ over the policy

Currently nla_policy_len always returns n * NLA_HDRLEN:
It loops, but does not advance it's iterator. NLA_UNSPEC == 0 does not contain a .len in any policy.

Trivially fixed by adding p++.

lib/nlattr.c +1 -1
index 5021cbc..ac09f22 100644
@@ -148,7 +148,7 @@ nla_policy_len(const struct nla_policy *p, int n)
 {
 	int i, len = 0;
 
-	for (i = 0; i < n; i++) {
+	for (i = 0; i < n; i++, p++) {
 		if (p->len)
 			len += nla_total_size(p->len);
 		else if (nla_attr_minlen[p->type])
Applied
#1 lore raw

From: Lars Ellenberg <[email protected]>
Date: Mon, 28 Feb 2011 21:35:59 +0100

Quoted 7 lines

Currently nla_policy_len always returns n * NLA_HDRLEN:
It loops, but does not advance it's iterator. NLA_UNSPEC == 0 does not contain a .len in any policy.

Trivially fixed by adding p++.

Applied, thanks.

#2 lore raw
In reply to Lars Ellenberg

lib/nlattr.c

Quoted 9 lines · Lars Ellenberg

Currently nla_policy_len always returns n * NLA_HDRLEN:
It loops, but does not advance it's iterator. NLA_UNSPEC == 0 does not contain a .len in any policy.

Trivially fixed by adding p++.

lib/nlattr.c +0 -0

Please read how to properly get patches into the stable kernel tree in the file Documentation/stable_kernel_rules.txt (hint, randomly cc:ing [email protected] is NOT how to do it...)

thanks,

greg k-h