Commit 2749b75
floppy: fix reference leak on platform_device_register() failure
When platform_device_register() fails in do_floppy_init(), the embedded
struct device in floppy_device[drive] has already been initialized by
device_initialize(), but the failure path jumps to out_remove_drives
without dropping the device reference for the current drive.
Previously registered floppy devices are cleaned up in out_remove_drives,
but the device for the drive that fails registration is not, leading to
a reference leak.
The issue was identified by a static analysis tool I developed and
confirmed by manual review. Fix this by calling put_device() for the
current floppy device before jumping to the common cleanup path.
Fixes: 94fd0db ("[PATCH] Floppy: Add cmos attribute to floppy driver")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>1 parent 6b4d829 commit 2749b75
1 file changed
Lines changed: 7 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4724 | 4724 | | |
4725 | 4725 | | |
4726 | 4726 | | |
4727 | | - | |
| 4727 | + | |
| 4728 | + | |
4728 | 4729 | | |
4729 | | - | |
| 4730 | + | |
4730 | 4731 | | |
4731 | 4732 | | |
4732 | 4733 | | |
4733 | 4734 | | |
4734 | | - | |
| 4735 | + | |
| 4736 | + | |
| 4737 | + | |
4735 | 4738 | | |
| 4739 | + | |
4736 | 4740 | | |
4737 | 4741 | | |
4738 | 4742 | | |
| |||
0 commit comments