Skip to contentSkip to conversation

leds: class: Make led_remove_lookup() NULL-aware

PATCH Applied Andy Shevchenko 2 participants 2 messages Mar 27 – Apr 9 LED

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 leds: class: Make led_remove_lookup() NULL-aware

It is a usual pattern in the kernel to make releasing functions be NULL-aware so they become a no-op. This helps reducing unneeded checks in the code where the given resource is optional.

---
 drivers/leds/led-class.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/leds/led-class.c +3 -0
index d34a19453560..172fc44bb602 100644
@@ -421,6 +421,9 @@ EXPORT_SYMBOL_GPL(led_add_lookup);
  */
 void led_remove_lookup(struct led_lookup_data *led_lookup)
 {
+	if (!led_lookup)
+		return;
+
 	mutex_lock(&leds_lookup_lock);
 	list_del(&led_lookup->list);
 	mutex_unlock(&leds_lookup_lock);
Signature · 1 line
2.50.1
maintainer Applied
#1 lore raw

Re: (subset) [PATCH v1 1/1] leds: class: Make led_remove_lookup() NULL-aware

Quoted 3 lines · Andy Shevchenko

It is a usual pattern in the kernel to make releasing functions be NULL-aware so they become a no-op. This helps reducing unneeded checks in the code where the given resource is optional.

Applied, thanks!

[1/1] leds: class: Make led_remove_lookup() NULL-aware

      commit: 7a43ccf85dfe06eef483c034e68b81ff326741aa

--
Lee Jones [李琼斯]