public inbox for linux-gpio@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpio: sim: Remove intermediate pointer variable and harden function
@ 2026-04-23 22:32 Maxwell Doose
  2026-04-24  7:54 ` Bartosz Golaszewski
  0 siblings, 1 reply; 5+ messages in thread
From: Maxwell Doose @ 2026-04-23 22:32 UTC (permalink / raw)
  To: linusw, brgl; +Cc: linux-gpio, linux-kernel

Remove the *pdev intermediate variable and directly dereference the
pointer. While at it, replace sprintf() calls with sysfs_emit() to
harden the driver.

Signed-off-by: Maxwell Doose <m32285159@gmail.com>
---
 drivers/gpio/gpio-sim.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c
index 13b87c8e6d0c..3c230f94eea2 100644
--- a/drivers/gpio/gpio-sim.c
+++ b/drivers/gpio/gpio-sim.c
@@ -691,15 +691,13 @@ static ssize_t gpio_sim_device_config_dev_name_show(struct config_item *item,
 						    char *page)
 {
 	struct gpio_sim_device *dev = to_gpio_sim_device(item);
-	struct platform_device *pdev;
 
 	guard(mutex)(&dev->lock);
 
-	pdev = dev->probe_data.pdev;
-	if (pdev)
-		return sprintf(page, "%s\n", dev_name(&pdev->dev));
+	if (dev->probe_data.pdev)
+		return sysfs_emit(page, "%s\n", dev_name(&dev->probe_data.pdev->dev));
 
-	return sprintf(page, "gpio-sim.%d\n", dev->id);
+	return sysfs_emit(page, "gpio-sim.%d\n", dev->id);
 }
 
 CONFIGFS_ATTR_RO(gpio_sim_device_config_, dev_name);
-- 
2.53.0


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

end of thread, other threads:[~2026-04-24 13:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-23 22:32 [PATCH] gpio: sim: Remove intermediate pointer variable and harden function Maxwell Doose
2026-04-24  7:54 ` Bartosz Golaszewski
2026-04-24 13:05   ` Maxwell Doose
2026-04-24 13:13     ` Bartosz Golaszewski
2026-04-24 13:22       ` Maxwell Doose

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