Commit 1862c14e authored by Jiri Slaby's avatar Jiri Slaby Committed by Greg Kroah-Hartman

TTY: isdn/gigaset destroy tty_port properly

Currently, the port may be destroyed twice or destroyed without being
initialized. Fix this by sticking the destroy call in the right place
as suggested by Tilman.
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
Reported-by: default avatarTilman Schmidt <tilman@imap.cc>
Cc: Hansjoerg Lipp <hjlipp@web.de>
Cc: gigaset307x-common@lists.sourceforge.net
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a547e5e0
...@@ -507,6 +507,7 @@ void gigaset_freecs(struct cardstate *cs) ...@@ -507,6 +507,7 @@ void gigaset_freecs(struct cardstate *cs)
gig_dbg(DEBUG_INIT, "clearing at_state"); gig_dbg(DEBUG_INIT, "clearing at_state");
clear_at_state(&cs->at_state); clear_at_state(&cs->at_state);
dealloc_temp_at_states(cs); dealloc_temp_at_states(cs);
tty_port_destroy(&cs->port);
/* fall through */ /* fall through */
case 0: /* error in basic setup */ case 0: /* error in basic setup */
...@@ -518,7 +519,6 @@ f_bcs: gig_dbg(DEBUG_INIT, "freeing bcs[]"); ...@@ -518,7 +519,6 @@ f_bcs: gig_dbg(DEBUG_INIT, "freeing bcs[]");
kfree(cs->bcs); kfree(cs->bcs);
f_cs: gig_dbg(DEBUG_INIT, "freeing cs"); f_cs: gig_dbg(DEBUG_INIT, "freeing cs");
mutex_unlock(&cs->mutex); mutex_unlock(&cs->mutex);
tty_port_destroy(&cs->port);
free_cs(cs); free_cs(cs);
} }
EXPORT_SYMBOL_GPL(gigaset_freecs); EXPORT_SYMBOL_GPL(gigaset_freecs);
...@@ -752,14 +752,14 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, ...@@ -752,14 +752,14 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
gig_dbg(DEBUG_INIT, "setting up iif"); gig_dbg(DEBUG_INIT, "setting up iif");
if (gigaset_isdn_regdev(cs, modulename) < 0) { if (gigaset_isdn_regdev(cs, modulename) < 0) {
pr_err("error registering ISDN device\n"); pr_err("error registering ISDN device\n");
goto error_port; goto error;
} }
make_valid(cs, VALID_ID); make_valid(cs, VALID_ID);
++cs->cs_init; ++cs->cs_init;
gig_dbg(DEBUG_INIT, "setting up hw"); gig_dbg(DEBUG_INIT, "setting up hw");
if (cs->ops->initcshw(cs) < 0) if (cs->ops->initcshw(cs) < 0)
goto error_port; goto error;
++cs->cs_init; ++cs->cs_init;
...@@ -774,7 +774,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, ...@@ -774,7 +774,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
gig_dbg(DEBUG_INIT, "setting up bcs[%d]", i); gig_dbg(DEBUG_INIT, "setting up bcs[%d]", i);
if (gigaset_initbcs(cs->bcs + i, cs, i) < 0) { if (gigaset_initbcs(cs->bcs + i, cs, i) < 0) {
pr_err("could not allocate channel %d data\n", i); pr_err("could not allocate channel %d data\n", i);
goto error_port; goto error;
} }
} }
...@@ -787,8 +787,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, ...@@ -787,8 +787,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
gig_dbg(DEBUG_INIT, "cs initialized"); gig_dbg(DEBUG_INIT, "cs initialized");
return cs; return cs;
error_port:
tty_port_destroy(&cs->port);
error: error:
gig_dbg(DEBUG_INIT, "failed"); gig_dbg(DEBUG_INIT, "failed");
gigaset_freecs(cs); gigaset_freecs(cs);
......
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