Skip to content

Commit

Permalink
tty: do not check tty_unregister_driver's return value
Browse files Browse the repository at this point in the history
These drivers check tty_unregister_driver return value. But they don't
handle a failure correctly (they free the driver in any case). So stop
checking tty_unregister_driver return value and remove also the prints.

In the next patch, tty_unregister_driver's return type will be switched
to void.

Cc: Chris Zankel <[email protected]>
Cc: Max Filippov <[email protected]>
Cc: [email protected]
Cc: Jiri Kosina <[email protected]>
Cc: David Sterba <[email protected]>
Reviewed-by: Max Filippov <[email protected]>
Acked-by: David Sterba <[email protected]>
Signed-off-by: Jiri Slaby <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Jiri Slaby authored and gregkh committed Mar 10, 2021
1 parent ba444ea commit 6c2e631
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 27 deletions.
6 changes: 1 addition & 5 deletions arch/xtensa/platforms/iss/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,7 @@ static int __init rs_init(void)

static __exit void rs_exit(void)
{
int error;

if ((error = tty_unregister_driver(serial_driver)))
pr_err("ISS_SERIAL: failed to unregister serial driver (%d)\n",
error);
tty_unregister_driver(serial_driver);
put_tty_driver(serial_driver);
tty_port_destroy(&serial_port);
}
Expand Down
8 changes: 2 additions & 6 deletions drivers/tty/amiserial.c
Original file line number Diff line number Diff line change
Expand Up @@ -1622,21 +1622,17 @@ static int __init amiga_serial_probe(struct platform_device *pdev)

static int __exit amiga_serial_remove(struct platform_device *pdev)
{
int error;
struct serial_state *state = platform_get_drvdata(pdev);

/* printk("Unloading %s: version %s\n", serial_name, serial_version); */
error = tty_unregister_driver(serial_driver);
if (error)
printk("SERIAL: failed to unregister serial driver (%d)\n",
error);
tty_unregister_driver(serial_driver);
put_tty_driver(serial_driver);
tty_port_destroy(&state->tport);

free_irq(IRQ_AMIGA_TBE, state);
free_irq(IRQ_AMIGA_RBF, state);

return error;
return 0;
}

static struct platform_driver amiga_serial_driver = {
Expand Down
7 changes: 1 addition & 6 deletions drivers/tty/ipwireless/tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,13 +596,8 @@ int ipwireless_tty_init(void)

void ipwireless_tty_release(void)
{
int ret;

ret = tty_unregister_driver(ipw_tty_driver);
tty_unregister_driver(ipw_tty_driver);
put_tty_driver(ipw_tty_driver);
if (ret != 0)
printk(KERN_ERR IPWIRELESS_PCCARD_NAME
": tty_unregister_driver failed with code %d\n", ret);
}

int ipwireless_tty_is_modem(struct ipw_tty *tty)
Expand Down
4 changes: 1 addition & 3 deletions drivers/tty/moxa.c
Original file line number Diff line number Diff line change
Expand Up @@ -1118,9 +1118,7 @@ static void __exit moxa_exit(void)

del_timer_sync(&moxaTimer);

if (tty_unregister_driver(moxaDriver))
printk(KERN_ERR "Couldn't unregister MOXA Intellio family "
"serial driver\n");
tty_unregister_driver(moxaDriver);
put_tty_driver(moxaDriver);
}

Expand Down
4 changes: 1 addition & 3 deletions drivers/tty/serial/kgdb_nmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,7 @@ int kgdb_unregister_nmi_console(void)
if (ret)
return ret;

ret = tty_unregister_driver(kgdb_nmi_tty_driver);
if (ret)
return ret;
tty_unregister_driver(kgdb_nmi_tty_driver);
put_tty_driver(kgdb_nmi_tty_driver);

return 0;
Expand Down
5 changes: 1 addition & 4 deletions drivers/tty/synclink_gt.c
Original file line number Diff line number Diff line change
Expand Up @@ -3705,7 +3705,6 @@ static const struct tty_operations ops = {

static void slgt_cleanup(void)
{
int rc;
struct slgt_info *info;
struct slgt_info *tmp;

Expand All @@ -3714,9 +3713,7 @@ static void slgt_cleanup(void)
if (serial_driver) {
for (info=slgt_device_list ; info != NULL ; info=info->next_device)
tty_unregister_device(serial_driver, info->line);
rc = tty_unregister_driver(serial_driver);
if (rc)
DBGERR(("tty_unregister_driver error=%d\n", rc));
tty_unregister_driver(serial_driver);
put_tty_driver(serial_driver);
}

Expand Down

0 comments on commit 6c2e631

Please sign in to comment.