Skip to content

Commit 1a6ec67

Browse files
Yuan Cangregkh
authored andcommitted
serial: sunsab: Fix error handling in sunsab_init()
The sunsab_init() returns the platform_driver_register() directly without checking its return value, if platform_driver_register() failed, the allocated sunsab_ports is leaked. Fix by free sunsab_ports and set it to NULL when platform_driver_register() failed. Fixes: c4d3721 ("[SERIAL] sunsab: Convert to of_driver framework.") Signed-off-by: Yuan Can <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 1307c5d commit 1a6ec67

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/tty/serial/sunsab.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,13 @@ static int __init sunsab_init(void)
11311131
}
11321132
}
11331133

1134-
return platform_driver_register(&sab_driver);
1134+
err = platform_driver_register(&sab_driver);
1135+
if (err) {
1136+
kfree(sunsab_ports);
1137+
sunsab_ports = NULL;
1138+
}
1139+
1140+
return err;
11351141
}
11361142

11371143
static void __exit sunsab_exit(void)

0 commit comments

Comments
 (0)