Commit 303e8ebf authored by Jiri Slaby's avatar Jiri Slaby Committed by Greg Kroah-Hartman

ti-st: use goto-failpath in st_core_init

Use the classic failpath handling using gotos in st_core_init. That way,
tty_unregister_ldisc needs not be repeated on two places.
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
Cc: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20210505091928.22010-21-jslaby@suse.czSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f6f19595
...@@ -872,9 +872,8 @@ int st_core_init(struct st_data_s **core_data) ...@@ -872,9 +872,8 @@ int st_core_init(struct st_data_s **core_data)
st_gdata = kzalloc(sizeof(struct st_data_s), GFP_KERNEL); st_gdata = kzalloc(sizeof(struct st_data_s), GFP_KERNEL);
if (!st_gdata) { if (!st_gdata) {
pr_err("memory allocation failed"); pr_err("memory allocation failed");
tty_unregister_ldisc(&st_ldisc_ops);
err = -ENOMEM; err = -ENOMEM;
return err; goto err_unreg_ldisc;
} }
/* Initialize ST TxQ and Tx waitQ queue head. All BT/FM/GPS module skb's /* Initialize ST TxQ and Tx waitQ queue head. All BT/FM/GPS module skb's
...@@ -889,15 +888,18 @@ int st_core_init(struct st_data_s **core_data) ...@@ -889,15 +888,18 @@ int st_core_init(struct st_data_s **core_data)
err = st_ll_init(st_gdata); err = st_ll_init(st_gdata);
if (err) { if (err) {
pr_err("error during st_ll initialization(%ld)", err); pr_err("error during st_ll initialization(%ld)", err);
kfree(st_gdata); goto err_free_gdata;
tty_unregister_ldisc(&st_ldisc_ops);
return err;
} }
INIT_WORK(&st_gdata->work_write_wakeup, work_fn_write_wakeup); INIT_WORK(&st_gdata->work_write_wakeup, work_fn_write_wakeup);
*core_data = st_gdata; *core_data = st_gdata;
return 0; return 0;
err_free_gdata:
kfree(st_gdata);
err_unreg_ldisc:
tty_unregister_ldisc(&st_ldisc_ops);
return err;
} }
void st_core_exit(struct st_data_s *st_gdata) void st_core_exit(struct st_data_s *st_gdata)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment