Skip to contentSkip to conversation

leds: tlc591xx: fix device_node_continue.cocci warnings (fwd)

PATCH In review Julia Lawall 3 participants 4 messages Dec 6, 2018 – Dec 8, 2018 LED

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 leds: tlc591xx: fix device_node_continue.cocci warnings (fwd)

Hello,

The code seems to be wrong in several ways. If the continue is wanted, the of_node_put is not needed; it will happen on the next iteration. If the continue is not wanted, the of_node_put is needed, and the continue should be dropped.

julia

---------- Forwarded message ----------
Date: Thu, 6 Dec 2018 19:48:54 +0800
From: kbuild test robot <[email protected]>
To: [email protected]
Cc: Julia Lawall <[email protected]>
Subject: [PATCH] leds: tlc591xx: fix device_node_continue.cocci warnings

CC: [email protected]
TO: Jyri Sarha <[email protected]>
CC: Peter Ujfalusi <[email protected]>
CC: Jacek Anaszewski <[email protected]>
CC: Pavel Machek <[email protected]>
CC: [email protected]
CC: [email protected]

From: kbuild test robot <[email protected]>

drivers/leds/leds-tlc591xx.c:342:3-14: ERROR: probable double put.

Device node iterators put the previous value of the index variable, so an explicit put causes a double put.

Generated by: scripts/coccinelle/iterators/device_node_continue.cocci

Fixes 7b2d34aaede7 ("leds: tlc591xx: Add gpio output support")
CC Jyri Sarha <[email protected]>

---

tree:   https://github.com/omap-audio/linux-audio peter/ti-linux-4.19.y/wip
head:   838f24e2deaf1229002bd6555eb7e889b09ac1f9
commit: 7b2d34aaede727b4abfc78061bbd2202fcd92bc8 [62/67] leds: tlc591xx: Add gpio output support

:::::: branch date: 26 hours ago
:::::: commit date: 26 hours ago

Please take the patch only if it's a positive warning. Thanks!

 leds-tlc591xx.c |    1 -
 1 file changed, 1 deletion(-)
drivers/leds/leds-tlc591xx.c +0 -1
@@ -339,7 +339,6 @@ tlc591xx_probe(struct i2c_client *client
 	for_each_child_of_node(np, child) {
 		err = of_property_read_u32(child, "reg", &reg);
 		if (err) {
-			of_node_put(child);
 			continue;
 			return err;
 		}
#1 lore raw
Quoted 6 lines · Julia Lawall

Hello,

The code seems to be wrong in several ways. If the continue is wanted, the of_node_put is not needed; it will happen on the next iteration. If the continue is not wanted, the of_node_put is needed, and the continue should be dropped.

Yep, code is confusing. But the patch is bad, we don't want "continue; return;"

Hmm, continue seems more logical to me -- but I guess Jyri should decde?

Pavel

Quoted 50 lines

---------- Forwarded message ----------
Date: Thu, 6 Dec 2018 19:48:54 +0800
From: kbuild test robot <[email protected]>
To: [email protected]
Cc: Julia Lawall <[email protected]>
Subject: [PATCH] leds: tlc591xx: fix device_node_continue.cocci warnings

CC: [email protected]
TO: Jyri Sarha <[email protected]>
CC: Peter Ujfalusi <[email protected]>
CC: Jacek Anaszewski <[email protected]>
CC: Pavel Machek <[email protected]>
CC: [email protected]
CC: [email protected]

From: kbuild test robot <[email protected]>

drivers/leds/leds-tlc591xx.c:342:3-14: ERROR: probable double put.

Device node iterators put the previous value of the index variable, so an explicit put causes a double put.

Generated by: scripts/coccinelle/iterators/device_node_continue.cocci

Fixes 7b2d34aaede7 ("leds: tlc591xx: Add gpio output support")
CC Jyri Sarha <[email protected]>

---

tree:   https://github.com/omap-audio/linux-audio peter/ti-linux-4.19.y/wip
head:   838f24e2deaf1229002bd6555eb7e889b09ac1f9
commit: 7b2d34aaede727b4abfc78061bbd2202fcd92bc8 [62/67] leds: tlc591xx: Add gpio output support

:::::: branch date: 26 hours ago
:::::: commit date: 26 hours ago

Please take the patch only if it's a positive warning. Thanks!

 leds-tlc591xx.c |    1 -
 1 file changed, 1 deletion(-)
drivers/leds/leds-tlc591xx.c +0 -1
@@ -339,7 +339,6 @@ tlc591xx_probe(struct i2c_client *client
 	for_each_child_of_node(np, child) {
 		err = of_property_read_u32(child, "reg", &reg);
 		if (err) {
-			of_node_put(child);
 			continue;
 			return err;
 		}
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#2 lore raw
In reply to Julia Lawall

Hi Julia,

Thank you for the patch, but it doesn't apply to LED tree.

The patch causing the problem is out-of-LED-tree.

Best regards,
Jacek Anaszewski

Quoted 60 lines · Julia Lawall

Hello,

The code seems to be wrong in several ways. If the continue is wanted, the of_node_put is not needed; it will happen on the next iteration. If the continue is not wanted, the of_node_put is needed, and the continue should be dropped.

julia

---------- Forwarded message ----------
Date: Thu, 6 Dec 2018 19:48:54 +0800
From: kbuild test robot <[email protected]>
To: [email protected]
Cc: Julia Lawall <[email protected]>
Subject: [PATCH] leds: tlc591xx: fix device_node_continue.cocci warnings

CC: [email protected]
TO: Jyri Sarha <[email protected]>
CC: Peter Ujfalusi <[email protected]>
CC: Jacek Anaszewski <[email protected]>
CC: Pavel Machek <[email protected]>
CC: [email protected]
CC: [email protected]

From: kbuild test robot <[email protected]>

drivers/leds/leds-tlc591xx.c:342:3-14: ERROR: probable double put.

Device node iterators put the previous value of the index variable, so an explicit put causes a double put.

Generated by: scripts/coccinelle/iterators/device_node_continue.cocci

Fixes 7b2d34aaede7 ("leds: tlc591xx: Add gpio output support")
CC Jyri Sarha <[email protected]>

---

tree:   https://github.com/omap-audio/linux-audio peter/ti-linux-4.19.y/wip
head:   838f24e2deaf1229002bd6555eb7e889b09ac1f9
commit: 7b2d34aaede727b4abfc78061bbd2202fcd92bc8 [62/67] leds: tlc591xx: Add gpio output support

:::::: branch date: 26 hours ago
:::::: commit date: 26 hours ago

Please take the patch only if it's a positive warning. Thanks!

  leds-tlc591xx.c |    1 -
  1 file changed, 1 deletion(-)
drivers/leds/leds-tlc591xx.c +0 -1
@@ -339,7 +339,6 @@ tlc591xx_probe(struct i2c_client *client
  	for_each_child_of_node(np, child) {
  		err = of_property_read_u32(child, "reg", &reg);
  		if (err) {
-			of_node_put(child);
  			continue;
  			return err;
  		}
#3 lore raw
Quoted 5 lines · Jacek Anaszewski

Hi Julia,

Thank you for the patch, but it doesn't apply to LED tree.

The patch causing the problem is out-of-LED-tree.

OK, I guess that the patch is in a TI-specific tree, given the name.

Thanks for looking into it.

julia

Quoted 69 lines

Best regards,
Jacek Anaszewski

Quoted 61 lines · Julia Lawall

Hello,

The code seems to be wrong in several ways. If the continue is wanted, the of_node_put is not needed; it will happen on the next iteration. If the continue is not wanted, the of_node_put is needed, and the continue should be dropped.

julia

---------- Forwarded message ----------
Date: Thu, 6 Dec 2018 19:48:54 +0800
From: kbuild test robot <[email protected]>
To: [email protected]
Cc: Julia Lawall <[email protected]>
Subject: [PATCH] leds: tlc591xx: fix device_node_continue.cocci warnings

CC: [email protected]
TO: Jyri Sarha <[email protected]>
CC: Peter Ujfalusi <[email protected]>
CC: Jacek Anaszewski <[email protected]>
CC: Pavel Machek <[email protected]>
CC: [email protected]
CC: [email protected]

From: kbuild test robot <[email protected]>

drivers/leds/leds-tlc591xx.c:342:3-14: ERROR: probable double put.

Device node iterators put the previous value of the index variable, so an explicit put causes a double put.

Generated by: scripts/coccinelle/iterators/device_node_continue.cocci

Fixes 7b2d34aaede7 ("leds: tlc591xx: Add gpio output support")
CC Jyri Sarha <[email protected]>

---

tree:   https://github.com/omap-audio/linux-audio peter/ti-linux-4.19.y/wip
head:   838f24e2deaf1229002bd6555eb7e889b09ac1f9
commit: 7b2d34aaede727b4abfc78061bbd2202fcd92bc8 [62/67] leds: tlc591xx: Add

gpio output support
:::::: branch date: 26 hours ago
:::::: commit date: 26 hours ago

Please take the patch only if it's a positive warning. Thanks!

  leds-tlc591xx.c |    1 -
  1 file changed, 1 deletion(-)
drivers/leds/leds-tlc591xx.c +0 -1
@@ -339,7 +339,6 @@ tlc591xx_probe(struct i2c_client *client
  	for_each_child_of_node(np, child) {
  		err = of_property_read_u32(child, "reg", &reg);
  		if (err) {
-			of_node_put(child);
  			continue;
  			return err;
  		}