Skip to content

Commit 03a7ffe

Browse files
George Spelvingregkh
George Spelvin
authored andcommitted
pps: Use pps_lookup_dev to reduce ldisc coupling
Now that N_TTY uses tty->disc_data for its private data, 'subclass' ldiscs cannot use ->disc_data for their own private data. (This is a regression is v3.8-rc1) Use pps_lookup_dev to associate the tty with the pps source instead. This fixes a crashing regression in 3.8-rc1. Signed-off-by: George Spelvin <linux@horizon.com> Acked-by: Rodolfo Giometti <giometti@enneenne.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 513b032 commit 03a7ffe

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

drivers/pps/clients/pps-ldisc.c

+4-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
static void pps_tty_dcd_change(struct tty_struct *tty, unsigned int status,
3232
struct pps_event_time *ts)
3333
{
34-
struct pps_device *pps = (struct pps_device *)tty->disc_data;
34+
struct pps_device *pps = pps_lookup_dev(tty);
3535

3636
BUG_ON(pps == NULL);
3737

@@ -67,9 +67,9 @@ static int pps_tty_open(struct tty_struct *tty)
6767
pr_err("cannot register PPS source \"%s\"\n", info.path);
6868
return -ENOMEM;
6969
}
70-
tty->disc_data = pps;
70+
pps->lookup_cookie = tty;
7171

72-
/* Should open N_TTY ldisc too */
72+
/* Now open the base class N_TTY ldisc */
7373
ret = alias_n_tty_open(tty);
7474
if (ret < 0) {
7575
pr_err("cannot open tty ldisc \"%s\"\n", info.path);
@@ -81,7 +81,6 @@ static int pps_tty_open(struct tty_struct *tty)
8181
return 0;
8282

8383
err_unregister:
84-
tty->disc_data = NULL;
8584
pps_unregister_source(pps);
8685
return ret;
8786
}
@@ -90,11 +89,10 @@ static void (*alias_n_tty_close)(struct tty_struct *tty);
9089

9190
static void pps_tty_close(struct tty_struct *tty)
9291
{
93-
struct pps_device *pps = (struct pps_device *)tty->disc_data;
92+
struct pps_device *pps = pps_lookup_dev(tty);
9493

9594
alias_n_tty_close(tty);
9695

97-
tty->disc_data = NULL;
9896
dev_info(pps->dev, "removed\n");
9997
pps_unregister_source(pps);
10098
}

0 commit comments

Comments
 (0)