aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Thompson <daniel.thompson@linaro.org>2014-05-29 04:48:44 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-05-29 14:28:05 -0400
commit06d18289256ec58b78ae8d5b83ff70c3c34309f5 (patch)
treee6f11e28e4ace0453756822635a7460eb3f5046e
parent2fe686ebafb43414c406c4c6252ad388a871bf1a (diff)
serial: kgdb_nmi: Use container_of() to locate private data
This corrects a crash in kgdb_nmi_tty_shutdown() which occurs when the function is called with port->tty set to NULL. All conversions between struct tty_port and struct kgdb_nmi_tty_priv have been switched to direct calls to container_of() to improve code clarity and consistancy. Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/serial/kgdb_nmi.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/drivers/tty/serial/kgdb_nmi.c b/drivers/tty/serial/kgdb_nmi.c
index 5f673b7ca50e..d51b2a1ba909 100644
--- a/drivers/tty/serial/kgdb_nmi.c
+++ b/drivers/tty/serial/kgdb_nmi.c
@@ -84,11 +84,6 @@ struct kgdb_nmi_tty_priv {
84 STRUCT_KFIFO(char, KGDB_NMI_FIFO_SIZE) fifo; 84 STRUCT_KFIFO(char, KGDB_NMI_FIFO_SIZE) fifo;
85}; 85};
86 86
87static struct kgdb_nmi_tty_priv *kgdb_nmi_port_to_priv(struct tty_port *port)
88{
89 return container_of(port, struct kgdb_nmi_tty_priv, port);
90}
91
92/* 87/*
93 * Our debugging console is polled in a tasklet, so we'll check for input 88 * Our debugging console is polled in a tasklet, so we'll check for input
94 * every tick. In HZ-less mode, we should program the next tick. We have 89 * every tick. In HZ-less mode, we should program the next tick. We have
@@ -118,7 +113,7 @@ static void kgdb_tty_recv(int ch)
118 * do that, and actually, we can't: we're in NMI context, no locks are 113 * do that, and actually, we can't: we're in NMI context, no locks are
119 * possible. 114 * possible.
120 */ 115 */
121 priv = kgdb_nmi_port_to_priv(kgdb_nmi_port); 116 priv = container_of(kgdb_nmi_port, struct kgdb_nmi_tty_priv, port);
122 kfifo_in(&priv->fifo, &c, 1); 117 kfifo_in(&priv->fifo, &c, 1);
123 kgdb_tty_poke(); 118 kgdb_tty_poke();
124} 119}
@@ -216,7 +211,8 @@ static void kgdb_nmi_tty_receiver(unsigned long data)
216 211
217static int kgdb_nmi_tty_activate(struct tty_port *port, struct tty_struct *tty) 212static int kgdb_nmi_tty_activate(struct tty_port *port, struct tty_struct *tty)
218{ 213{
219 struct kgdb_nmi_tty_priv *priv = tty->driver_data; 214 struct kgdb_nmi_tty_priv *priv =
215 container_of(port, struct kgdb_nmi_tty_priv, port);
220 216
221 kgdb_nmi_port = port; 217 kgdb_nmi_port = port;
222 tasklet_schedule(&priv->tlet); 218 tasklet_schedule(&priv->tlet);
@@ -225,7 +221,8 @@ static int kgdb_nmi_tty_activate(struct tty_port *port, struct tty_struct *tty)
225 221
226static void kgdb_nmi_tty_shutdown(struct tty_port *port) 222static void kgdb_nmi_tty_shutdown(struct tty_port *port)
227{ 223{
228 struct kgdb_nmi_tty_priv *priv = port->tty->driver_data; 224 struct kgdb_nmi_tty_priv *priv =
225 container_of(port, struct kgdb_nmi_tty_priv, port);
229 226
230 tasklet_kill(&priv->tlet); 227 tasklet_kill(&priv->tlet);
231 kgdb_nmi_port = NULL; 228 kgdb_nmi_port = NULL;