All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Staging: ipack/devices/ipoctal: fix dereference NULL pointer
@ 2012-07-13 11:33 Samuel Iglesias Gonsálvez
  2012-07-13 11:33 ` [PATCH 2/2] Staging: ipack/devices/ipoctal: initialize the device in probe function Samuel Iglesias Gonsálvez
  0 siblings, 1 reply; 2+ messages in thread
From: Samuel Iglesias Gonsálvez @ 2012-07-13 11:33 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Samuel Iglesias Gonsálvez, devel, linux-kernel

After opening and closing the file /dev/ipoctal.X.Y.Z for the second time, it
gives a kernel oops due to a dereference of a NULL pointer.

The problem was that tty->driver_data was not properly initialized when
accessing the file for the second time.

Reported-by: Alberto Garcia Gonzalez <agarcia@igalia.com>
Signed-off-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
---
 drivers/staging/ipack/devices/ipoctal.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/ipack/devices/ipoctal.c b/drivers/staging/ipack/devices/ipoctal.c
index a5af423..a1aae40 100644
--- a/drivers/staging/ipack/devices/ipoctal.c
+++ b/drivers/staging/ipack/devices/ipoctal.c
@@ -114,8 +114,6 @@ static int ipoctal_port_activate(struct tty_port *port, struct tty_struct *tty)
 
 	ipoctal_write_io_reg(ipoctal, &ipoctal->chan_regs[channel].u.w.cr,
 			     CR_ENABLE_RX);
-	tty->driver_data = ipoctal;
-
 	return 0;
 }
 
@@ -136,6 +134,8 @@ static int ipoctal_open(struct tty_struct *tty, struct file *file)
 	if (atomic_read(&ipoctal->open[channel]))
 		return -EBUSY;
 
+	tty->driver_data = ipoctal;
+
 	res = tty_port_open(&ipoctal->tty_port[channel], tty, file);
 	if (res)
 		return res;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] Staging: ipack/devices/ipoctal: initialize the device in probe function
  2012-07-13 11:33 [PATCH 1/2] Staging: ipack/devices/ipoctal: fix dereference NULL pointer Samuel Iglesias Gonsálvez
@ 2012-07-13 11:33 ` Samuel Iglesias Gonsálvez
  0 siblings, 0 replies; 2+ messages in thread
From: Samuel Iglesias Gonsálvez @ 2012-07-13 11:33 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Samuel Iglesias Gonsálvez, devel, linux-kernel

Initialize the device when registering it. Sometimes the user access to it
and the device is in an unknown state, so it could fail.

Signed-off-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
---
 drivers/staging/ipack/devices/ipoctal.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/staging/ipack/devices/ipoctal.c b/drivers/staging/ipack/devices/ipoctal.c
index a1aae40..fd0e301 100644
--- a/drivers/staging/ipack/devices/ipoctal.c
+++ b/drivers/staging/ipack/devices/ipoctal.c
@@ -411,6 +411,20 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr,
 	for (i = 0; i < NR_CHANNELS ; i++) {
 		ipoctal_write_io_reg(ipoctal, &ipoctal->chan_regs[i].u.w.cr,
 				     CR_DISABLE_RX | CR_DISABLE_TX);
+		ipoctal_write_cr_cmd(ipoctal, &ipoctal->chan_regs[i].u.w.cr,
+				     CR_CMD_RESET_RX);
+		ipoctal_write_cr_cmd(ipoctal, &ipoctal->chan_regs[i].u.w.cr,
+				     CR_CMD_RESET_TX);
+		ipoctal_write_io_reg(ipoctal,
+				     &ipoctal->chan_regs[i].u.w.mr,
+				     MR1_CHRL_8_BITS | MR1_ERROR_CHAR |
+				     MR1_RxINT_RxRDY); /* mr1 */
+		ipoctal_write_io_reg(ipoctal,
+				     &ipoctal->chan_regs[i].u.w.mr,
+				     0); /* mr2 */
+		ipoctal_write_io_reg(ipoctal,
+				     &ipoctal->chan_regs[i].u.w.csr,
+				     TX_CLK_9600  | RX_CLK_9600);
 	}
 
 	for (i = 0; i < IP_OCTAL_NB_BLOCKS; i++) {
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-07-13 11:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-13 11:33 [PATCH 1/2] Staging: ipack/devices/ipoctal: fix dereference NULL pointer Samuel Iglesias Gonsálvez
2012-07-13 11:33 ` [PATCH 2/2] Staging: ipack/devices/ipoctal: initialize the device in probe function Samuel Iglesias Gonsálvez

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.