Skip to contentSkip to conversation

aoe: error printed 1 too early

PATCH Applied Roel Kluin 3 participants 6 messages Feb 25, 2009 – Mar 4, 2009

Subsystems (2)
lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 aoe: error printed 1 too early

with while (i-- > 0); i reaches -1 after the loop, so the test below is printed one too early: 0 still means success.

---

drivers/block/aoe/aoedev.c +1 -1
index cc25057..eeea477 100644
@@ -173,7 +173,7 @@ skbfree(struct sk_buff *skb)
 		return;
 	while (atomic_read(&skb_shinfo(skb)->dataref) != 1 && i-- > 0)
 		msleep(Sms);
-	if (i <= 0) {
+	if (i < 0) {
 		printk(KERN_ERR
 			"aoe: %s holds ref: %s\n",
 			skb->dev ? skb->dev->name : "netif",
#1 lore raw
Quoted 11 lines · Roel Kluin

with while (i-- > 0); i reaches -1 after the loop, so the test below is printed one too early: 0 still means success.

---

drivers/block/aoe/aoedev.c +0 -0
index cc25057..eeea477 100644

drivers/block/aoe/aoedev.c skbfree(struct sk_buff *skb) · line 179

Quoted 8 lines
drivers/block/aoe/aoedev.c +1 -1
@@ -173,7 +173,7 @@ skbfree(struct sk_buff *skb)
 		return;
 	while (atomic_read(&skb_shinfo(skb)->dataref) != 1 && i-- > 0)
 		msleep(Sms);
-	if (i <= 0) {
+	if (i < 0) {
 		printk(KERN_ERR
 			"aoe: %s holds ref: %s\n",
 			skb->dev ? skb->dev->name : "netif",

You are talking about the case where, when entering the loop on the "last chance" iteration, the states are,

atomic_read(&skb_shinfo(skb)->dataref == 1
i == 0

... in which case, the skb can and should be used but is not used because after the value of i is tested it becomes -1.

Right?

Sounds like a good catch. Did you find it because you saw the "cannot free skb" message?

Signature · 1 line
  Ed Cashin <[email protected]>
#2 lore raw

From: Ed Cashin <[email protected]>
Date: Wed, 25 Feb 2009 12:09:02 -0500

Quoted 2 lines

Sounds like a good catch. Did you find it because you saw the "cannot free skb" message?

He's finding these by looking for them in the code, not by actually triggering the condition.

#3 lore raw
Quoted 8 lines · David Miller

From: Ed Cashin <[email protected]>
Date: Wed, 25 Feb 2009 12:09:02 -0500

Quoted 2 lines

Sounds like a good catch. Did you find it because you saw the "cannot free skb" message?

He's finding these by looking for them in the code, not by actually triggering the condition.

Thanks. I was curious.

Signature · 1 line
  Ed Cashin <[email protected]>
author
#4 lore raw
In reply to David Miller

2009/2/25 David Miller <[email protected]>:

Quoted 9 lines

From: Ed Cashin <[email protected]>
Date: Wed, 25 Feb 2009 12:09:02 -0500

Quoted 2 lines

Sounds like a good catch.  Did you find it because you saw the "cannot free skb" message?

He's finding these by looking for them in the code, not by actually triggering the condition.

Actually I made all functions a single line and then run some bash scripts that parses pseudocode like:

echo "INFO: \7 reaches \9 - 1 after loop"
bli "

	if \((${npz}[&|][&|])?
		--($w) $em?[<=] ($K|$w|$d)
		((&&|\|\|)$(nestedcode "()"))?\)
	(\{
		($(nestedcode "{}"))*
		break ;
	\}|
		break ;
	)
	$ccode
	(
		$Q(\7 [=$em]= \9|\7 (>=|<) \9)
	|
		return \7 ;
	)
	"

This gives me a match like:

  while(...) {
    if (--i < 0)
      break;
    ...
  }
  ...
  if (i != 0)
    ...

which is wrong since i reaches -1.