Skip to content

Commit 7dc774f

Browse files
committed
Merge tag 'gpio-fixes-for-v6.15-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux
Pull gpio fixes from Bartosz Golaszewski: - fix an interrupt storm on system wake-up in gpio-pca953x - fix an out-of-bounds write in gpio-virtuser - update MAINTAINERS with an entry for the sloppy logic analyzer * tag 'gpio-fixes-for-v6.15-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: gpio: virtuser: fix potential out-of-bound write gpio: pca953x: fix IRQ storm on system wake up MAINTAINERS: add me as maintainer for the gpio sloppy logic analyzer
2 parents 04811c3 + 7118be7 commit 7dc774f

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

MAINTAINERS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10147,6 +10147,13 @@ F: drivers/gpio/gpio-regmap.c
1014710147
F: include/linux/gpio/regmap.h
1014810148
K: (devm_)?gpio_regmap_(un)?register
1014910149

10150+
GPIO SLOPPY LOGIC ANALYZER
10151+
M: Wolfram Sang <wsa+renesas@sang-engineering.com>
10152+
S: Supported
10153+
F: Documentation/dev-tools/gpio-sloppy-logic-analyzer.rst
10154+
F: drivers/gpio/gpio-sloppy-logic-analyzer.c
10155+
F: tools/gpio/gpio-sloppy-logic-analyzer.sh
10156+
1015010157
GPIO SUBSYSTEM
1015110158
M: Linus Walleij <linus.walleij@linaro.org>
1015210159
M: Bartosz Golaszewski <brgl@bgdev.pl>

drivers/gpio/gpio-pca953x.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,8 @@ static int pca953x_restore_context(struct pca953x_chip *chip)
12041204

12051205
guard(mutex)(&chip->i2c_lock);
12061206

1207+
if (chip->client->irq > 0)
1208+
enable_irq(chip->client->irq);
12071209
regcache_cache_only(chip->regmap, false);
12081210
regcache_mark_dirty(chip->regmap);
12091211
ret = pca953x_regcache_sync(chip);
@@ -1216,6 +1218,10 @@ static int pca953x_restore_context(struct pca953x_chip *chip)
12161218
static void pca953x_save_context(struct pca953x_chip *chip)
12171219
{
12181220
guard(mutex)(&chip->i2c_lock);
1221+
1222+
/* Disable IRQ to prevent early triggering while regmap "cache only" is on */
1223+
if (chip->client->irq > 0)
1224+
disable_irq(chip->client->irq);
12191225
regcache_cache_only(chip->regmap, true);
12201226
}
12211227

drivers/gpio/gpio-virtuser.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,10 +401,15 @@ static ssize_t gpio_virtuser_direction_do_write(struct file *file,
401401
char buf[32], *trimmed;
402402
int ret, dir, val = 0;
403403

404-
ret = simple_write_to_buffer(buf, sizeof(buf), ppos, user_buf, count);
404+
if (count >= sizeof(buf))
405+
return -EINVAL;
406+
407+
ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count);
405408
if (ret < 0)
406409
return ret;
407410

411+
buf[ret] = '\0';
412+
408413
trimmed = strim(buf);
409414

410415
if (strcmp(trimmed, "input") == 0) {
@@ -623,12 +628,15 @@ static ssize_t gpio_virtuser_consumer_write(struct file *file,
623628
char buf[GPIO_VIRTUSER_NAME_BUF_LEN + 2];
624629
int ret;
625630

631+
if (count >= sizeof(buf))
632+
return -EINVAL;
633+
626634
ret = simple_write_to_buffer(buf, GPIO_VIRTUSER_NAME_BUF_LEN, ppos,
627635
user_buf, count);
628636
if (ret < 0)
629637
return ret;
630638

631-
buf[strlen(buf) - 1] = '\0';
639+
buf[ret] = '\0';
632640

633641
ret = gpiod_set_consumer_name(data->ad.desc, buf);
634642
if (ret)

0 commit comments

Comments
 (0)