Skip to contentSkip to conversation

leds: triggers: return error if invalid trigger name is provided via sysfs

PATCH In review Heiner Kallweit 2 participants 2 messages Jul 1, 2016 – Jul 4, 2016 LED

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 leds: triggers: return error if invalid trigger name is provided via sysfs

If an invalid trigger name is provided via sysfs currently no error is returned. Therefore it's not possible to determine whether the trigger was set successfully.
Fix this by returning -EINVAL if no trigger is matched.

---
 drivers/leds/led-triggers.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/leds/led-triggers.c +2 -0
index 55fa65e..c92702a 100644
@@ -60,6 +60,8 @@ ssize_t led_trigger_store(struct device *dev, struct device_attribute *attr,
 			goto unlock;
 		}
 	}
+	/* we come here only if buf matches no trigger */
+	ret = -EINVAL;
 	up_read(&triggers_list_lock);
 
 unlock:
Signature · 1 line
2.9.0
#1 lore raw

Hi Heiner,

Quoted 16 lines · Heiner Kallweit

If an invalid trigger name is provided via sysfs currently no error is returned. Therefore it's not possible to determine whether the trigger was set successfully.
Fix this by returning -EINVAL if no trigger is matched.

---
  drivers/leds/led-triggers.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/leds/led-triggers.c +0 -0
index 55fa65e..c92702a 100644

drivers/leds/led-triggers.c ssize_t led_trigger_store(struct device *dev, struct device_attribute *attr, · line 67

Quoted 8 lines
drivers/leds/led-triggers.c +2 -0
@@ -60,6 +60,8 @@ ssize_t led_trigger_store(struct device *dev, struct device_attribute *attr,
  			goto unlock;
  		}
  	}
+	/* we come here only if buf matches no trigger */
+	ret = -EINVAL;
  	up_read(&triggers_list_lock);
 
  unlock:

Thanks for the patch. Applied.

Signature · 2 lines
Best regards,
Jacek Anaszewski