Subject: [PATCH 1/4] Staging: ipack/devices/ipoctal: fix oops when accessing "buffer"

The buffer[][] field was replaced by tty_port->xmit_buf field but there was
some places that "buffer" was still accessed, giving a kernel oops because
it was uninitialized.

Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]>
---
drivers/staging/ipack/devices/ipoctal.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/ipack/devices/ipoctal.c b/drivers/staging/ipack/devices/ipoctal.c
index 2921467..7fe1c93 100644
--- a/drivers/staging/ipack/devices/ipoctal.c
+++ b/drivers/staging/ipack/devices/ipoctal.c
@@ -46,7 +46,6 @@ struct ipoctal {
struct scc2698_channel *chan_regs;
struct scc2698_block *block_regs;
struct ipoctal_stats chan_stats[NR_CHANNELS];
- char *buffer[NR_CHANNELS];
unsigned int nb_bytes[NR_CHANNELS];
unsigned int count_wr[NR_CHANNELS];
wait_queue_head_t queue[NR_CHANNELS];
@@ -305,7 +304,7 @@ static int ipoctal_irq_handler(void *arg)
continue;
}
spin_lock(&ipoctal->lock[channel]);
- value = ipoctal->buffer[channel][*pointer_write];
+ value = ipoctal->tty_port[channel].xmit_buf[*pointer_write];
ipoctal_write_io_reg(ipoctal,
&ipoctal->chan_regs[channel].u.w.thr,
value);
--
1.7.10


Subject: [PATCH 4/4] Staging: ipack/devices/ipoctal: remove unneeded lock in IRQ handler

In the rest of the code, the data is protected with spin_lock_irqsave().

Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]>
---
drivers/staging/ipack/devices/ipoctal.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/ipack/devices/ipoctal.c b/drivers/staging/ipack/devices/ipoctal.c
index b11126d..ec7b2f9 100644
--- a/drivers/staging/ipack/devices/ipoctal.c
+++ b/drivers/staging/ipack/devices/ipoctal.c
@@ -299,7 +299,7 @@ static int ipoctal_irq_handler(void *arg)
ipoctal->nb_bytes[channel] = 0;
continue;
}
- spin_lock(&ipoctal->lock[channel]);
+
value = ipoctal->tty_port[channel].xmit_buf[*pointer_write];
ipoctal_write_io_reg(ipoctal,
&ipoctal->chan_regs[channel].u.w.thr,
@@ -309,7 +309,6 @@ static int ipoctal_irq_handler(void *arg)
(*pointer_write)++;
*pointer_write = *pointer_write % PAGE_SIZE;
ipoctal->nb_bytes[channel]--;
- spin_unlock(&ipoctal->lock[channel]);

if ((ipoctal->nb_bytes[channel] == 0) &&
(waitqueue_active(&ipoctal->queue[channel]))) {
--
1.7.10

Subject: [PATCH 3/4] Staging: ipack/bridges/tpci200: remove unneeded lock in irq handler

Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]>
---
drivers/staging/ipack/bridges/tpci200.c | 5 -----
drivers/staging/ipack/bridges/tpci200.h | 2 --
2 files changed, 7 deletions(-)

diff --git a/drivers/staging/ipack/bridges/tpci200.c b/drivers/staging/ipack/bridges/tpci200.c
index ae9f803..2b83fa8 100644
--- a/drivers/staging/ipack/bridges/tpci200.c
+++ b/drivers/staging/ipack/bridges/tpci200.c
@@ -302,13 +302,10 @@ static irqreturn_t tpci200_interrupt(int irq, void *dev_id)
{
struct tpci200_board *tpci200 = (struct tpci200_board *) dev_id;
int i;
- unsigned long flags;
unsigned short status_reg, reg_value;
unsigned short unhandled_ints = 0;
irqreturn_t ret = IRQ_NONE;

- spin_lock_irqsave(&tpci200->info->access_lock, flags);
-
/* Read status register */
status_reg = readw(tpci200->info->interface_regs +
TPCI200_STATUS_REG);
@@ -351,7 +348,6 @@ static irqreturn_t tpci200_interrupt(int irq, void *dev_id)
}
}

- spin_unlock_irqrestore(&tpci200->info->access_lock, flags);
return ret;
}

@@ -414,7 +410,6 @@ static int tpci200_register(struct tpci200_board *tpci200)
TPCI200_MEM8_SPACE_BAR),
TPCI200_MEM8_SIZE);

- spin_lock_init(&tpci200->info->access_lock);
ioidint_base = pci_resource_start(tpci200->info->pdev,
TPCI200_IO_ID_INT_SPACES_BAR);
mem_base = pci_resource_start(tpci200->info->pdev,
diff --git a/drivers/staging/ipack/bridges/tpci200.h b/drivers/staging/ipack/bridges/tpci200.h
index 97ff0d6..d04510a 100644
--- a/drivers/staging/ipack/bridges/tpci200.h
+++ b/drivers/staging/ipack/bridges/tpci200.h
@@ -136,7 +136,6 @@ struct tpci200_slot {
* @interface_regs Pointer to IP interface space (Bar 2)
* @ioidint_space Pointer to IP ID, IO and INT space (Bar 3)
* @mem8_space Pointer to MEM space (Bar 4)
- * @access_lock Mutex lock for simultaneous access
*
*/
struct tpci200_infos {
@@ -145,7 +144,6 @@ struct tpci200_infos {
void __iomem *interface_regs;
void __iomem *ioidint_space;
void __iomem *mem8_space;
- spinlock_t access_lock;
struct ipack_bus_device *ipack_bus;
};
struct tpci200_board {
--
1.7.10

Subject: [PATCH 2/4] Staging: ipack/devices/ipoctal: remove unneeded includes

Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]>
---
drivers/staging/ipack/devices/ipoctal.c | 4 ----
1 file changed, 4 deletions(-)

diff --git a/drivers/staging/ipack/devices/ipoctal.c b/drivers/staging/ipack/devices/ipoctal.c
index 7fe1c93..b11126d 100644
--- a/drivers/staging/ipack/devices/ipoctal.c
+++ b/drivers/staging/ipack/devices/ipoctal.c
@@ -13,16 +13,12 @@

#include <linux/device.h>
#include <linux/module.h>
-#include <linux/moduleparam.h>
#include <linux/interrupt.h>
-#include <linux/fs.h>
-#include <linux/delay.h>
#include <linux/sched.h>
#include <linux/tty.h>
#include <linux/serial.h>
#include <linux/tty_flip.h>
#include <linux/slab.h>
-#include <linux/uaccess.h>
#include <linux/atomic.h>
#include "../ipack.h"
#include "ipoctal.h"
--
1.7.10