mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] gpio: lock device when calling device_is_bound()
@ 2026-05-18  9:53 Bartosz Golaszewski
  2026-05-18  9:53 ` [PATCH 1/3] gpio: sim: " Bartosz Golaszewski
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Bartosz Golaszewski @ 2026-05-18  9:53 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Geert Uytterhoeven
  Cc: linux-gpio, linux-kernel, Bartosz Golaszewski

The kerneldoc for device_is_bound() says it must be called with the
device lock taken. Add missing synchronization to GPIO modules using it.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Bartosz Golaszewski (3):
      gpio: sim: lock device when calling device_is_bound()
      gpio: aggregator: lock device when calling device_is_bound()
      gpio: virtuser: lock device when calling device_is_bound()

 drivers/gpio/gpio-aggregator.c |  9 ++++++---
 drivers/gpio/gpio-sim.c        | 11 +++++++----
 drivers/gpio/gpio-virtuser.c   |  9 ++++++---
 3 files changed, 19 insertions(+), 10 deletions(-)
---
base-commit: 5200f5f493f79f14bbdc349e402a40dfb32f23c8
change-id: 20260518-gpio-dev-lock-827253e58535

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] gpio: sim: lock device when calling device_is_bound()
  2026-05-18  9:53 [PATCH 0/3] gpio: lock device when calling device_is_bound() Bartosz Golaszewski
@ 2026-05-18  9:53 ` Bartosz Golaszewski
  2026-05-18  9:53 ` [PATCH 2/3] gpio: aggregator: " Bartosz Golaszewski
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Bartosz Golaszewski @ 2026-05-18  9:53 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Geert Uytterhoeven
  Cc: linux-gpio, linux-kernel, Bartosz Golaszewski

The kerneldoc for device_is_bound() says it must be called with the
device lock taken. Add missing synchronization to this driver.

Fixes: 7fb3287946f9 ("gpio: sim: stop using dev-sync-probe")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/gpio/gpio-sim.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c
index e19701c2ed673f8ec5a2475e632388197a78339c..0da2c5a45843ea22ef39273c2e39dc128664f0b2 100644
--- a/drivers/gpio/gpio-sim.c
+++ b/drivers/gpio/gpio-sim.c
@@ -901,7 +901,7 @@ static int gpio_sim_device_activate(struct gpio_sim_device *dev)
 	struct platform_device *pdev;
 	struct fwnode_handle *swnode;
 	struct gpio_sim_bank *bank;
-	int ret;
+	int ret = 0;
 
 	lockdep_assert_held(&dev->lock);
 
@@ -945,9 +945,12 @@ static int gpio_sim_device_activate(struct gpio_sim_device *dev)
 	}
 
 	wait_for_device_probe();
-	if (!device_is_bound(&pdev->dev)) {
-		ret = -ENXIO;
-		goto err_unregister_pdev;
+
+	scoped_guard(device, &pdev->dev) {
+		if (!device_is_bound(&pdev->dev)) {
+			ret = -ENXIO;
+			goto err_unregister_pdev;
+		}
 	}
 
 	dev->pdev = pdev;

-- 
2.47.3


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/3] gpio: aggregator: lock device when calling device_is_bound()
  2026-05-18  9:53 [PATCH 0/3] gpio: lock device when calling device_is_bound() Bartosz Golaszewski
  2026-05-18  9:53 ` [PATCH 1/3] gpio: sim: " Bartosz Golaszewski
@ 2026-05-18  9:53 ` Bartosz Golaszewski
  2026-05-18  9:53 ` [PATCH 3/3] gpio: virtuser: " Bartosz Golaszewski
  2026-05-21 12:38 ` [PATCH 0/3] gpio: " Bartosz Golaszewski
  3 siblings, 0 replies; 5+ messages in thread
From: Bartosz Golaszewski @ 2026-05-18  9:53 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Geert Uytterhoeven
  Cc: linux-gpio, linux-kernel, Bartosz Golaszewski

The kerneldoc for device_is_bound() says it must be called with the
device lock taken. Add missing synchronization to this driver.

Fixes: 3a27f40b4570 ("gpio: aggregator: stop using dev-sync-probe")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/gpio/gpio-aggregator.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-aggregator.c b/drivers/gpio/gpio-aggregator.c
index 5915209e1e2168b0932de4d16aff38074b889c2b..3dbccb14216f8450ac0f68abaab693e52b9d1bf4 100644
--- a/drivers/gpio/gpio-aggregator.c
+++ b/drivers/gpio/gpio-aggregator.c
@@ -968,9 +968,12 @@ static int gpio_aggregator_activate(struct gpio_aggregator *aggr)
 	}
 
 	wait_for_device_probe();
-	if (!device_is_bound(&pdev->dev)) {
-		ret = -ENXIO;
-		goto err_unregister_pdev;
+
+	scoped_guard(device, &pdev->dev) {
+		if (!device_is_bound(&pdev->dev)) {
+			ret = -ENXIO;
+			goto err_unregister_pdev;
+		}
 	}
 
 	aggr->pdev = pdev;

-- 
2.47.3


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 3/3] gpio: virtuser: lock device when calling device_is_bound()
  2026-05-18  9:53 [PATCH 0/3] gpio: lock device when calling device_is_bound() Bartosz Golaszewski
  2026-05-18  9:53 ` [PATCH 1/3] gpio: sim: " Bartosz Golaszewski
  2026-05-18  9:53 ` [PATCH 2/3] gpio: aggregator: " Bartosz Golaszewski
@ 2026-05-18  9:53 ` Bartosz Golaszewski
  2026-05-21 12:38 ` [PATCH 0/3] gpio: " Bartosz Golaszewski
  3 siblings, 0 replies; 5+ messages in thread
From: Bartosz Golaszewski @ 2026-05-18  9:53 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Geert Uytterhoeven
  Cc: linux-gpio, linux-kernel, Bartosz Golaszewski

The kerneldoc for device_is_bound() says it must be called with the
device lock taken. Add missing synchronization to this driver.

Fixes: c3e2a8aef28c ("gpio: virtuser: stop using dev-sync-probe")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/gpio/gpio-virtuser.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-virtuser.c b/drivers/gpio/gpio-virtuser.c
index fe0eac920ced323926b2bc83ca0a2eb5f85c2154..128520d340d46cbaa36b492cbdcb996bade93d77 100644
--- a/drivers/gpio/gpio-virtuser.c
+++ b/drivers/gpio/gpio-virtuser.c
@@ -1477,9 +1477,12 @@ gpio_virtuser_device_activate(struct gpio_virtuser_device *dev)
 	}
 
 	wait_for_device_probe();
-	if (!device_is_bound(&pdev->dev)) {
-		ret = -ENXIO;
-		goto err_unregister_pdev;
+
+	scoped_guard(device, &pdev->dev) {
+		if (!device_is_bound(&pdev->dev)) {
+			ret = -ENXIO;
+			goto err_unregister_pdev;
+		}
 	}
 
 	dev->pdev = pdev;

-- 
2.47.3


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/3] gpio: lock device when calling device_is_bound()
  2026-05-18  9:53 [PATCH 0/3] gpio: lock device when calling device_is_bound() Bartosz Golaszewski
                   ` (2 preceding siblings ...)
  2026-05-18  9:53 ` [PATCH 3/3] gpio: virtuser: " Bartosz Golaszewski
@ 2026-05-21 12:38 ` Bartosz Golaszewski
  3 siblings, 0 replies; 5+ messages in thread
From: Bartosz Golaszewski @ 2026-05-21 12:38 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Geert Uytterhoeven,
	Bartosz Golaszewski
  Cc: linux-gpio, linux-kernel


On Mon, 18 May 2026 11:53:16 +0200, Bartosz Golaszewski wrote:
> The kerneldoc for device_is_bound() says it must be called with the
> device lock taken. Add missing synchronization to GPIO modules using it.
> 
> 

Applied, thanks!

[1/3] gpio: sim: lock device when calling device_is_bound()
      https://git.kernel.org/brgl/c/e70ae40d6660c5428c790c329318c570b4d038ab
[2/3] gpio: aggregator: lock device when calling device_is_bound()
      https://git.kernel.org/brgl/c/598a2b3e2e0e6aa2e9f7843c96c45b5ea11e0411
[3/3] gpio: virtuser: lock device when calling device_is_bound()
      https://git.kernel.org/brgl/c/a4fa45c1d980bc2b9837f469119af24a9304a1fc

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-05-21 12:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-18  9:53 [PATCH 0/3] gpio: lock device when calling device_is_bound() Bartosz Golaszewski
2026-05-18  9:53 ` [PATCH 1/3] gpio: sim: " Bartosz Golaszewski
2026-05-18  9:53 ` [PATCH 2/3] gpio: aggregator: " Bartosz Golaszewski
2026-05-18  9:53 ` [PATCH 3/3] gpio: virtuser: " Bartosz Golaszewski
2026-05-21 12:38 ` [PATCH 0/3] gpio: " Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®