Skip to contentSkip to conversation

gpio: mxc: Unlock on error path in mxc_flip_edge()

PATCH Applied Dan Carpenter 3 participants 3 messages Jan 24, 2023 – Jan 25, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: mxc: Unlock on error path in mxc_flip_edge()

We recently added locking to this function but one error path was over looked. Drop the lock before returning.

Fixes e5464277625c ("gpio: mxc: Protect GPIO irqchip RMW with bgpio spinlock")
---
 drivers/gpio/gpio-mxc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpio/gpio-mxc.c +2 -1
index 6f673b2f2a1b..9d0cec4b82a3 100644
@@ -249,10 +249,11 @@ static void mxc_flip_edge(struct mxc_gpio_port *port, u32 gpio)
 	} else {
 		pr_err("mxc: invalid configuration for GPIO %d: %x\n",
 		       gpio, edge);
-		return;
+		goto unlock;
 	}
 	writel(val | (edge << (bit << 1)), reg);
 
+unlock:
 	raw_spin_unlock_irqrestore(&port->gc.bgpio_lock, flags);
 }
 
Signature · 1 line
2.35.1
Acked-by on v1 1/1
#1 lore raw
Quoted 15 lines · Dan Carpenter

We recently added locking to this function but one error path was over looked. Drop the lock before returning.

Fixes e5464277625c ("gpio: mxc: Protect GPIO irqchip RMW with bgpio spinlock")
---
  drivers/gpio/gpio-mxc.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpio/gpio-mxc.c +0 -0
index 6f673b2f2a1b..9d0cec4b82a3 100644
@@ -249,10 +249,11 @@ static void mxc_flip_edge(struct mxc_gpio_port *port, u32 gpio)
  	} else {

drivers/gpio/gpio-mxc.c static void mxc_flip_edge(struct mxc_gpio_port *port, u32 gpio) · line 258

Quoted 10 lines
drivers/gpio/gpio-mxc.c +2 -1
  		pr_err("mxc: invalid configuration for GPIO %d: %x\n",
  		       gpio, edge);
-		return;
+		goto unlock;
  	}
  	writel(val | (edge << (bit << 1)), reg);
 
+unlock:
  	raw_spin_unlock_irqrestore(&port->gc.bgpio_lock, flags);
  }

Thanks !

#2 lore raw
In reply to Dan Carpenter
Quoted 28 lines · Dan Carpenter

We recently added locking to this function but one error path was over looked. Drop the lock before returning.

Fixes e5464277625c ("gpio: mxc: Protect GPIO irqchip RMW with bgpio spinlock")
---
 drivers/gpio/gpio-mxc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpio/gpio-mxc.c +2 -2
index 6f673b2f2a1b..9d0cec4b82a3 100644
@@ -249,10 +249,11 @@ static void mxc_flip_edge(struct mxc_gpio_port *port, u32 gpio)
        } else {
                pr_err("mxc: invalid configuration for GPIO %d: %x\n",
                       gpio, edge);
-               return;
+               goto unlock;
        }
        writel(val | (edge << (bit << 1)), reg);
 
+unlock:
        raw_spin_unlock_irqrestore(&port->gc.bgpio_lock, flags);
 }
 
--
Quoted 2 lines

2.35.1

Queued for fixes, thanks!

Bart