Skip to content

Commit bb8a4fc

Browse files
jhovoldgregkh
authored andcommitted
ipack: ipoctal: fix module reference leak
A reference to the carrier module was taken on every open but was only released once when the final reference to the tty struct was dropped. Fix this by taking the module reference and initialising the tty driver data when installing the tty. Fixes: 82a8234 ("ipoctal: get carrier driver to avoid rmmod") Cc: [email protected] # 3.18 Cc: Federico Vaga <[email protected]> Acked-by: Samuel Iglesias Gonsalvez <[email protected]> Signed-off-by: Johan Hovold <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 445c813 commit bb8a4fc

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

drivers/ipack/devices/ipoctal.c

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,22 +82,34 @@ static int ipoctal_port_activate(struct tty_port *port, struct tty_struct *tty)
8282
return 0;
8383
}
8484

85-
static int ipoctal_open(struct tty_struct *tty, struct file *file)
85+
static int ipoctal_install(struct tty_driver *driver, struct tty_struct *tty)
8686
{
8787
struct ipoctal_channel *channel = dev_get_drvdata(tty->dev);
8888
struct ipoctal *ipoctal = chan_to_ipoctal(channel, tty->index);
89-
int err;
90-
91-
tty->driver_data = channel;
89+
int res;
9290

9391
if (!ipack_get_carrier(ipoctal->dev))
9492
return -EBUSY;
9593

96-
err = tty_port_open(&channel->tty_port, tty, file);
97-
if (err)
98-
ipack_put_carrier(ipoctal->dev);
94+
res = tty_standard_install(driver, tty);
95+
if (res)
96+
goto err_put_carrier;
97+
98+
tty->driver_data = channel;
99+
100+
return 0;
101+
102+
err_put_carrier:
103+
ipack_put_carrier(ipoctal->dev);
104+
105+
return res;
106+
}
107+
108+
static int ipoctal_open(struct tty_struct *tty, struct file *file)
109+
{
110+
struct ipoctal_channel *channel = tty->driver_data;
99111

100-
return err;
112+
return tty_port_open(&channel->tty_port, tty, file);
101113
}
102114

103115
static void ipoctal_reset_stats(struct ipoctal_stats *stats)
@@ -661,6 +673,7 @@ static void ipoctal_cleanup(struct tty_struct *tty)
661673

662674
static const struct tty_operations ipoctal_fops = {
663675
.ioctl = NULL,
676+
.install = ipoctal_install,
664677
.open = ipoctal_open,
665678
.close = ipoctal_close,
666679
.write = ipoctal_write_tty,

0 commit comments

Comments
 (0)