* [PATCH v1 1/1] leds: class: Make led_remove_lookup() NULL-aware
@ 2026-03-27 10:27 Andy Shevchenko
0 siblings, 0 replies; only message in thread
From: Andy Shevchenko @ 2026-03-27 10:27 UTC (permalink / raw)
To: Hans de Goede, linux-leds, linux-kernel
Cc: Lee Jones, Pavel Machek, 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.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/leds/led-class.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index d34a19453560..172fc44bb602 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -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);
--
2.50.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-03-27 10:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-27 10:27 [PATCH v1 1/1] leds: class: Make led_remove_lookup() NULL-aware Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox