Skip to content

Commit 25054b2

Browse files
feckertlag-linaro
authored andcommitted
leds: ledtrig-tty: Free allocated ttyname buffer on deactivate
The ttyname buffer for the ledtrig_tty_data struct is allocated in the sysfs ttyname_store() function. This buffer must be released on trigger deactivation. This was missing and is thus a memory leak. While we are at it, the TTY handler in the ledtrig_tty_data struct should also be returned in case of the trigger deactivation call. Cc: [email protected] Fixes: fd4a641 ("leds: trigger: implement a tty trigger") Signed-off-by: Florian Eckert <[email protected]> Reviewed-by: Uwe Kleine-König <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 736214b commit 25054b2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/leds/trigger/ledtrig-tty.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ static void ledtrig_tty_deactivate(struct led_classdev *led_cdev)
168168

169169
cancel_delayed_work_sync(&trigger_data->dwork);
170170

171+
kfree(trigger_data->ttyname);
172+
tty_kref_put(trigger_data->tty);
173+
trigger_data->tty = NULL;
174+
171175
kfree(trigger_data);
172176
}
173177

0 commit comments

Comments
 (0)