All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mfd: tps65911-comparator: fix sysfs file creation rollback
@ 2026-06-15  6:50 Pengpeng Hou
  2026-07-01 22:04 ` Lee Jones
  0 siblings, 1 reply; 2+ messages in thread
From: Pengpeng Hou @ 2026-06-15  6:50 UTC (permalink / raw)
  To: Lee Jones, linux-kernel; +Cc: pengpeng

tps65911_comparator_probe() creates comp1_threshold and then
comp2_threshold sysfs files.

If creating comp1_threshold fails, the probe still tries to create
comp2_threshold and can return success if the second creation succeeds.
If creating comp2_threshold fails, the already-created comp1_threshold
file is left behind even though probe returns an error.

Return immediately on comp1_threshold creation failure and remove
comp1_threshold when comp2_threshold creation fails.

Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
 drivers/mfd/tps65911-comparator.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/tps65911-comparator.c b/drivers/mfd/tps65911-comparator.c
index 7098712ea008..2e5211374aaf 100644
--- a/drivers/mfd/tps65911-comparator.c
+++ b/drivers/mfd/tps65911-comparator.c
@@ -130,12 +130,16 @@ static int tps65911_comparator_probe(struct platform_device *pdev)
 
 	/* Create sysfs entry */
 	ret = device_create_file(&pdev->dev, &dev_attr_comp1_threshold);
-	if (ret < 0)
+	if (ret < 0) {
 		dev_err(&pdev->dev, "failed to add COMP1 sysfs file\n");
+		return ret;
+	}
 
 	ret = device_create_file(&pdev->dev, &dev_attr_comp2_threshold);
-	if (ret < 0)
+	if (ret < 0) {
 		dev_err(&pdev->dev, "failed to add COMP2 sysfs file\n");
+		device_remove_file(&pdev->dev, &dev_attr_comp1_threshold);
+	}
 
 	return ret;
 }
-- 
2.50.1 (Apple Git-155)


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

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

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-15  6:50 [PATCH] mfd: tps65911-comparator: fix sysfs file creation rollback Pengpeng Hou
2026-07-01 22:04 ` Lee Jones

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.