Commit 243ba2fa461a22e01e5905dd299babeaeeb418e2

Authored by Jesper Nilsson
1 parent a3af54ffa9

CRIS: Check if pointer is set before using it

Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>

Showing 1 changed file with 12 additions and 8 deletions Side-by-side Diff

arch/cris/include/arch-v32/arch/io.h
... ... @@ -46,10 +46,12 @@
46 46 unsigned long flags;
47 47 spin_lock_irqsave(&iopin->port->lock, flags);
48 48  
49   - if (val)
50   - *iopin->port->data |= iopin->bit;
51   - else
52   - *iopin->port->data &= ~iopin->bit;
  49 + if (iopin->port->data) {
  50 + if (val)
  51 + *iopin->port->data |= iopin->bit;
  52 + else
  53 + *iopin->port->data &= ~iopin->bit;
  54 + }
53 55  
54 56 spin_unlock_irqrestore(&iopin->port->lock, flags);
55 57 }
... ... @@ -60,10 +62,12 @@
60 62 unsigned long flags;
61 63 spin_lock_irqsave(&iopin->port->lock, flags);
62 64  
63   - if (dir == crisv32_io_dir_in)
64   - *iopin->port->oe &= ~iopin->bit;
65   - else
66   - *iopin->port->oe |= iopin->bit;
  65 + if (iopin->port->oe) {
  66 + if (dir == crisv32_io_dir_in)
  67 + *iopin->port->oe &= ~iopin->bit;
  68 + else
  69 + *iopin->port->oe |= iopin->bit;
  70 + }
67 71  
68 72 spin_unlock_irqrestore(&iopin->port->lock, flags);
69 73 }