Commit 3ae72f6
ALSA: control led: fix memory leak in snd_ctl_led_register
The snd_ctl_led_sysfs_add and snd_ctl_led_sysfs_remove should contain
the refcount operations in pair. However, snd_ctl_led_sysfs_remove fails
to decrease the refcount to zero, which causes device_release never to
be invoked. This leads to memory leak to some resources, like struct
device_private. In addition, we also free some other similar memory
leaks in snd_ctl_led_init/snd_ctl_led_exit.
Fix this by replacing device_del to device_unregister
in snd_ctl_led_sysfs_remove/snd_ctl_led_init/snd_ctl_led_exit.
Note that, when CONFIG_DEBUG_KOBJECT_RELEASE is enabled, put_device will
call kobject_release and delay the release of kobject, which will cause
use-after-free when the memory backing the kobject is freed at once.
Reported-by: syzbot+08a7d8b51ea048a74ffb@syzkaller.appspotmail.com
Fixes: a135dfb ("ALSA: led control - add sysfs kcontrol LED marking layer")
Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20210602034136.2762497-1-mudongliangabcd@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>1 parent 901be14 commit 3ae72f6
1 file changed
Lines changed: 26 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
20 | 23 | | |
21 | 24 | | |
22 | 25 | | |
| |||
371 | 374 | | |
372 | 375 | | |
373 | 376 | | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
374 | 392 | | |
375 | 393 | | |
376 | 394 | | |
| |||
663 | 681 | | |
664 | 682 | | |
665 | 683 | | |
| 684 | + | |
666 | 685 | | |
667 | 686 | | |
668 | 687 | | |
| |||
681 | 700 | | |
682 | 701 | | |
683 | 702 | | |
684 | | - | |
685 | 703 | | |
686 | 704 | | |
687 | 705 | | |
| |||
700 | 718 | | |
701 | 719 | | |
702 | 720 | | |
703 | | - | |
704 | | - | |
| 721 | + | |
705 | 722 | | |
706 | 723 | | |
707 | 724 | | |
| |||
723 | 740 | | |
724 | 741 | | |
725 | 742 | | |
| 743 | + | |
726 | 744 | | |
727 | 745 | | |
728 | 746 | | |
| |||
733 | 751 | | |
734 | 752 | | |
735 | 753 | | |
| 754 | + | |
736 | 755 | | |
737 | 756 | | |
738 | 757 | | |
739 | 758 | | |
740 | 759 | | |
741 | 760 | | |
742 | | - | |
| 761 | + | |
743 | 762 | | |
744 | | - | |
| 763 | + | |
745 | 764 | | |
746 | 765 | | |
747 | 766 | | |
| |||
767 | 786 | | |
768 | 787 | | |
769 | 788 | | |
770 | | - | |
| 789 | + | |
771 | 790 | | |
772 | | - | |
| 791 | + | |
773 | 792 | | |
774 | 793 | | |
775 | 794 | | |
| |||
0 commit comments