All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] misc: ad525x_dpot: fix sysfs cleanup paths
@ 2026-06-15  6:51 Pengpeng Hou
  2026-06-15  6:58 ` Greg Kroah-Hartman
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Pengpeng Hou @ 2026-06-15  6:51 UTC (permalink / raw)
  To: Michael Hennerich, Arnd Bergmann, Greg Kroah-Hartman,
	linux-kernel; +Cc: pengpeng

ad_dpot_probe() creates per-RDAC sysfs files and then, for devices with
increment/decrement commands, creates the command sysfs group.

If creating the command group fails, the probe error path frees the
driver data without removing the per-RDAC files created earlier.
Conversely, ad_dpot_remove() removes the per-RDAC files but never
removes the command group.

Route command-group creation failure through the existing per-RDAC
cleanup path and remove the command group during normal teardown.

Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
 drivers/misc/ad525x_dpot.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/ad525x_dpot.c b/drivers/misc/ad525x_dpot.c
index 57bead9fba1b..866fdddd8b0e 100644
--- a/drivers/misc/ad525x_dpot.c
+++ b/drivers/misc/ad525x_dpot.c
@@ -719,7 +719,7 @@ int ad_dpot_probe(struct device *dev,
 
 	if (err) {
 		dev_err(dev, "failed to register sysfs hooks\n");
-		goto exit_free;
+		goto exit_remove_files;
 	}
 
 	dev_info(dev, "%s %d-Position Digital Potentiometer registered\n",
@@ -751,6 +751,9 @@ void ad_dpot_remove(struct device *dev)
 		if (data->wipers & (1 << i))
 			ad_dpot_remove_files(dev, data->feat, i);
 
+	if (data->feat & F_CMD_INC)
+		sysfs_remove_group(&dev->kobj, &ad525x_group_commands);
+
 	kfree(data);
 }
 EXPORT_SYMBOL(ad_dpot_remove);
-- 
2.50.1 (Apple Git-155)


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

end of thread, other threads:[~2026-06-15 15:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-15  6:51 [PATCH] misc: ad525x_dpot: fix sysfs cleanup paths Pengpeng Hou
2026-06-15  6:58 ` Greg Kroah-Hartman
2026-06-15 12:25 ` kernel test robot
2026-06-15 15:37 ` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.