]> granicus.if.org Git - intel_nuc_led/commitdiff
Update nuc_led.c
authormilesp20 <milesp@gmail.com>
Tue, 8 May 2018 02:08:42 +0000 (22:08 -0400)
committerGitHub <noreply@github.com>
Tue, 8 May 2018 02:08:42 +0000 (22:08 -0400)
fix memory leak when parsing input params

nuc_led.c

index 36cf9ce67bf723dfe9bb2e49dcfcec2ade8c4a0e..c975f228254bf057229d35207d1b6850a0d06fda 100644 (file)
--- a/nuc_led.c
+++ b/nuc_led.c
@@ -225,7 +225,7 @@ static ssize_t acpi_proc_write(struct file *filp, const char __user *buff,
 {
         int i = 0;
         int ret = 0;
-        char *input, *arg;
+        char *input, *arg, *sep;
         static int status  = 0;
         struct led_set_state_return retval;
         u32 led, brightness, blink_fade, color_state;
@@ -244,7 +244,8 @@ static ssize_t acpi_proc_write(struct file *filp, const char __user *buff,
                 input[len - 1] = '\0';
 
         // Parse input string
-        while ((arg = strsep(&input, ",")) && *arg)
+       sep = input;
+        while ((arg = strsep(&sep, ",")) && *arg)
         {
                 if (i == 0)             // First arg: LED ("power" or "ring")
                 {