Skip to content

Commit ca45720

Browse files
committed
Merge tag 'gpio-v4.6-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio
Pull GPIO fixes from Linus Walleij: "Here are two GPIO fixes for the v4.6 series, both in drivers: - Prevent NULL dereference in the Xgene driver - Fix an uninitialized spinlock in the menz127 driver" * tag 'gpio-v4.6-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: gpio: xgene: Prevent NULL pointer dereference gpio: menz127: Drop lock field from struct men_z127_gpio
2 parents c5bce40 + 8d8ee18 commit ca45720

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

drivers/gpio/gpio-menz127.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ struct men_z127_gpio {
3737
void __iomem *reg_base;
3838
struct mcb_device *mdev;
3939
struct resource *mem;
40-
spinlock_t lock;
4140
};
4241

4342
static int men_z127_debounce(struct gpio_chip *gc, unsigned gpio,
@@ -69,7 +68,7 @@ static int men_z127_debounce(struct gpio_chip *gc, unsigned gpio,
6968
debounce /= 50;
7069
}
7170

72-
spin_lock(&priv->lock);
71+
spin_lock(&gc->bgpio_lock);
7372

7473
db_en = readl(priv->reg_base + MEN_Z127_DBER);
7574

@@ -84,7 +83,7 @@ static int men_z127_debounce(struct gpio_chip *gc, unsigned gpio,
8483
writel(db_en, priv->reg_base + MEN_Z127_DBER);
8584
writel(db_cnt, priv->reg_base + GPIO_TO_DBCNT_REG(gpio));
8685

87-
spin_unlock(&priv->lock);
86+
spin_unlock(&gc->bgpio_lock);
8887

8988
return 0;
9089
}
@@ -97,7 +96,7 @@ static int men_z127_request(struct gpio_chip *gc, unsigned gpio_pin)
9796
if (gpio_pin >= gc->ngpio)
9897
return -EINVAL;
9998

100-
spin_lock(&priv->lock);
99+
spin_lock(&gc->bgpio_lock);
101100
od_en = readl(priv->reg_base + MEN_Z127_ODER);
102101

103102
if (gpiochip_line_is_open_drain(gc, gpio_pin))
@@ -106,7 +105,7 @@ static int men_z127_request(struct gpio_chip *gc, unsigned gpio_pin)
106105
od_en &= ~BIT(gpio_pin);
107106

108107
writel(od_en, priv->reg_base + MEN_Z127_ODER);
109-
spin_unlock(&priv->lock);
108+
spin_unlock(&gc->bgpio_lock);
110109

111110
return 0;
112111
}

drivers/gpio/gpio-xgene.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ static int xgene_gpio_probe(struct platform_device *pdev)
173173
}
174174

175175
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
176+
if (!res) {
177+
err = -EINVAL;
178+
goto err;
179+
}
180+
176181
gpio->base = devm_ioremap_nocache(&pdev->dev, res->start,
177182
resource_size(res));
178183
if (!gpio->base) {

0 commit comments

Comments
 (0)