CRIS: Check if pointer is set before using it
authorJesper Nilsson <jesper.nilsson@axis.com>
Tue, 3 Aug 2010 16:50:06 +0000 (18:50 +0200)
committerJesper Nilsson <jesper.nilsson@axis.com>
Wed, 4 Aug 2010 11:02:34 +0000 (13:02 +0200)
Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
arch/cris/include/arch-v32/arch/io.h

index 7202445..adc5484 100644 (file)
@@ -46,10 +46,12 @@ static inline void crisv32_io_set(struct crisv32_iopin *iopin, int val)
        unsigned long flags;
        spin_lock_irqsave(&iopin->port->lock, flags);
 
-       if (val)
-               *iopin->port->data |= iopin->bit;
-       else
-               *iopin->port->data &= ~iopin->bit;
+       if (iopin->port->data) {
+               if (val)
+                       *iopin->port->data |= iopin->bit;
+               else
+                       *iopin->port->data &= ~iopin->bit;
+       }
 
        spin_unlock_irqrestore(&iopin->port->lock, flags);
 }
@@ -60,10 +62,12 @@ static inline void crisv32_io_set_dir(struct crisv32_iopin* iopin,
        unsigned long flags;
        spin_lock_irqsave(&iopin->port->lock, flags);
 
-       if (dir == crisv32_io_dir_in)
-               *iopin->port->oe &= ~iopin->bit;
-       else
-               *iopin->port->oe |= iopin->bit;
+       if (iopin->port->oe) {
+               if (dir == crisv32_io_dir_in)
+                       *iopin->port->oe &= ~iopin->bit;
+               else
+                       *iopin->port->oe |= iopin->bit;
+       }
 
        spin_unlock_irqrestore(&iopin->port->lock, flags);
 }