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

* Re: [PATCH] misc: ad525x_dpot: fix sysfs cleanup paths
  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
  2 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2026-06-15  6:58 UTC (permalink / raw)
  To: Pengpeng Hou; +Cc: Michael Hennerich, Arnd Bergmann, linux-kernel

On Mon, Jun 15, 2026 at 02:51:40PM +0800, Pengpeng Hou wrote:
> ad_dpot_probe() creates per-RDAC sysfs files and then, for devices with
> increment/decrement commands, creates the command sysfs group.

Which is the incorrect way of creating sysfs files for many reasons, not
the least being what you found here.

Please fix this by using a default group and the is_visable() callback
instead.  That way it will "just work" as the driver core will handle
all of this properly.

Huge hint, whenever a driver calls a sysfs_*() function, it is doing
something wrong.

thanks,

greg k-h

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

* Re: [PATCH] misc: ad525x_dpot: fix sysfs cleanup paths
  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
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2026-06-15 12:25 UTC (permalink / raw)
  To: Pengpeng Hou, Michael Hennerich, Arnd Bergmann,
	Greg Kroah-Hartman, linux-kernel
  Cc: oe-kbuild-all, pengpeng

Hi Pengpeng,

kernel test robot noticed the following build warnings:

[auto build test WARNING on char-misc/char-misc-testing]
[also build test WARNING on char-misc/char-misc-next char-misc/char-misc-linus soc/for-next linus/master v7.1 next-20260612]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Pengpeng-Hou/misc-ad525x_dpot-fix-sysfs-cleanup-paths/20260615-153833
base:   char-misc/char-misc-testing
patch link:    https://lore.kernel.org/r/20260615065140.77960-1-pengpeng%40iscas.ac.cn
patch subject: [PATCH] misc: ad525x_dpot: fix sysfs cleanup paths
config: s390-randconfig-001-20260615 (https://download.01.org/0day-ci/archive/20260615/202606152048.vvWJ0aYH-lkp@intel.com/config)
compiler: s390-linux-gcc (GCC) 11.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260615/202606152048.vvWJ0aYH-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202606152048.vvWJ0aYH-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/misc/ad525x_dpot.c: In function 'ad_dpot_probe':
>> drivers/misc/ad525x_dpot.c:735:1: warning: label 'exit_free' defined but not used [-Wunused-label]
     735 | exit_free:
         | ^~~~~~~~~


vim +/exit_free +735 drivers/misc/ad525x_dpot.c

4eb174bee6f862 Michael Hennerich 2009-12-14  685  
6c536e4ce8edd6 Michael Hennerich 2010-05-24  686  	struct dpot_data *data;
6c536e4ce8edd6 Michael Hennerich 2010-05-24  687  	int i, err = 0;
4eb174bee6f862 Michael Hennerich 2009-12-14  688  
bf4afc53b77aea Linus Torvalds    2026-02-21  689  	data = kzalloc_obj(struct dpot_data);
4eb174bee6f862 Michael Hennerich 2009-12-14  690  	if (!data) {
4eb174bee6f862 Michael Hennerich 2009-12-14  691  		err = -ENOMEM;
4eb174bee6f862 Michael Hennerich 2009-12-14  692  		goto exit;
4eb174bee6f862 Michael Hennerich 2009-12-14  693  	}
4eb174bee6f862 Michael Hennerich 2009-12-14  694  
6c536e4ce8edd6 Michael Hennerich 2010-05-24  695  	dev_set_drvdata(dev, data);
4eb174bee6f862 Michael Hennerich 2009-12-14  696  	mutex_init(&data->update_lock);
4eb174bee6f862 Michael Hennerich 2009-12-14  697  
6c536e4ce8edd6 Michael Hennerich 2010-05-24  698  	data->bdata = *bdata;
7f3379de9cd91e Michael Hennerich 2011-11-18  699  	data->devid = devid;
6c536e4ce8edd6 Michael Hennerich 2010-05-24  700  
7f3379de9cd91e Michael Hennerich 2011-11-18  701  	data->max_pos = 1 << DPOT_MAX_POS(devid);
6c536e4ce8edd6 Michael Hennerich 2010-05-24  702  	data->rdac_mask = data->max_pos - 1;
7f3379de9cd91e Michael Hennerich 2011-11-18  703  	data->feat = DPOT_FEAT(devid);
7f3379de9cd91e Michael Hennerich 2011-11-18  704  	data->uid = DPOT_UID(devid);
7f3379de9cd91e Michael Hennerich 2011-11-18  705  	data->wipers = DPOT_WIPERS(devid);
6c536e4ce8edd6 Michael Hennerich 2010-05-24  706  
59592d0ccc0000 Michael Hennerich 2010-05-24  707  	for (i = DPOT_RDAC0; i < MAX_RDACS; i++)
6c536e4ce8edd6 Michael Hennerich 2010-05-24  708  		if (data->wipers & (1 << i)) {
6c536e4ce8edd6 Michael Hennerich 2010-05-24  709  			err = ad_dpot_add_files(dev, data->feat, i);
6c536e4ce8edd6 Michael Hennerich 2010-05-24  710  			if (err)
6c536e4ce8edd6 Michael Hennerich 2010-05-24  711  				goto exit_remove_files;
6c536e4ce8edd6 Michael Hennerich 2010-05-24  712  			/* power-up midscale */
6c536e4ce8edd6 Michael Hennerich 2010-05-24  713  			if (data->feat & F_RDACS_WONLY)
6c536e4ce8edd6 Michael Hennerich 2010-05-24  714  				data->rdac_cache[i] = data->max_pos / 2;
4eb174bee6f862 Michael Hennerich 2009-12-14  715  		}
4eb174bee6f862 Michael Hennerich 2009-12-14  716  
6c536e4ce8edd6 Michael Hennerich 2010-05-24  717  	if (data->feat & F_CMD_INC)
6c536e4ce8edd6 Michael Hennerich 2010-05-24  718  		err = sysfs_create_group(&dev->kobj, &ad525x_group_commands);
6c536e4ce8edd6 Michael Hennerich 2010-05-24  719  
4eb174bee6f862 Michael Hennerich 2009-12-14  720  	if (err) {
4eb174bee6f862 Michael Hennerich 2009-12-14  721  		dev_err(dev, "failed to register sysfs hooks\n");
45f33069c7f509 Pengpeng Hou      2026-06-15  722  		goto exit_remove_files;
4eb174bee6f862 Michael Hennerich 2009-12-14  723  	}
4eb174bee6f862 Michael Hennerich 2009-12-14  724  
4eb174bee6f862 Michael Hennerich 2009-12-14  725  	dev_info(dev, "%s %d-Position Digital Potentiometer registered\n",
7f3379de9cd91e Michael Hennerich 2011-11-18  726  		 name, data->max_pos);
4eb174bee6f862 Michael Hennerich 2009-12-14  727  
4eb174bee6f862 Michael Hennerich 2009-12-14  728  	return 0;
4eb174bee6f862 Michael Hennerich 2009-12-14  729  
6c536e4ce8edd6 Michael Hennerich 2010-05-24  730  exit_remove_files:
59592d0ccc0000 Michael Hennerich 2010-05-24  731  	for (i = DPOT_RDAC0; i < MAX_RDACS; i++)
6c536e4ce8edd6 Michael Hennerich 2010-05-24  732  		if (data->wipers & (1 << i))
6c536e4ce8edd6 Michael Hennerich 2010-05-24  733  			ad_dpot_remove_files(dev, data->feat, i);
6c536e4ce8edd6 Michael Hennerich 2010-05-24  734  
4eb174bee6f862 Michael Hennerich 2009-12-14 @735  exit_free:
4eb174bee6f862 Michael Hennerich 2009-12-14  736  	kfree(data);
6c536e4ce8edd6 Michael Hennerich 2010-05-24  737  	dev_set_drvdata(dev, NULL);
4eb174bee6f862 Michael Hennerich 2009-12-14  738  exit:
6c536e4ce8edd6 Michael Hennerich 2010-05-24  739  	dev_err(dev, "failed to create client for %s ID 0x%lX\n",
7f3379de9cd91e Michael Hennerich 2011-11-18  740  		name, devid);
4eb174bee6f862 Michael Hennerich 2009-12-14  741  	return err;
4eb174bee6f862 Michael Hennerich 2009-12-14  742  }
6c536e4ce8edd6 Michael Hennerich 2010-05-24  743  EXPORT_SYMBOL(ad_dpot_probe);
4eb174bee6f862 Michael Hennerich 2009-12-14  744  

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH] misc: ad525x_dpot: fix sysfs cleanup paths
  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
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2026-06-15 15:37 UTC (permalink / raw)
  To: Pengpeng Hou, Michael Hennerich, Arnd Bergmann,
	Greg Kroah-Hartman, linux-kernel
  Cc: llvm, oe-kbuild-all, pengpeng

Hi Pengpeng,

kernel test robot noticed the following build warnings:

[auto build test WARNING on char-misc/char-misc-testing]
[also build test WARNING on char-misc/char-misc-next char-misc/char-misc-linus soc/for-next linus/master v7.1 next-20260612]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Pengpeng-Hou/misc-ad525x_dpot-fix-sysfs-cleanup-paths/20260615-153833
base:   char-misc/char-misc-testing
patch link:    https://lore.kernel.org/r/20260615065140.77960-1-pengpeng%40iscas.ac.cn
patch subject: [PATCH] misc: ad525x_dpot: fix sysfs cleanup paths
config: s390-randconfig-002-20260615 (https://download.01.org/0day-ci/archive/20260615/202606152348.ZvNcZYgS-lkp@intel.com/config)
compiler: clang version 23.0.0git (https://github.com/llvm/llvm-project e19d1f51a2c80b63cd8ca95bcc757b7077112808)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260615/202606152348.ZvNcZYgS-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202606152348.ZvNcZYgS-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/misc/ad525x_dpot.c:735:1: warning: unused label 'exit_free' [-Wunused-label]
     735 | exit_free:
         | ^~~~~~~~~~
   1 warning generated.

Kconfig warnings: (for reference only)
   WARNING: unmet direct dependencies detected for MFD_STMFX
   Depends on [n]: HAS_IOMEM [=y] && I2C [=m] && OF [=n]
   Selected by [m]:
   - PINCTRL_STMFX [=m] && PINCTRL [=y] && I2C [=m] && HAS_IOMEM [=y]


vim +/exit_free +735 drivers/misc/ad525x_dpot.c

4eb174bee6f862 Michael Hennerich 2009-12-14  685  
6c536e4ce8edd6 Michael Hennerich 2010-05-24  686  	struct dpot_data *data;
6c536e4ce8edd6 Michael Hennerich 2010-05-24  687  	int i, err = 0;
4eb174bee6f862 Michael Hennerich 2009-12-14  688  
bf4afc53b77aea Linus Torvalds    2026-02-21  689  	data = kzalloc_obj(struct dpot_data);
4eb174bee6f862 Michael Hennerich 2009-12-14  690  	if (!data) {
4eb174bee6f862 Michael Hennerich 2009-12-14  691  		err = -ENOMEM;
4eb174bee6f862 Michael Hennerich 2009-12-14  692  		goto exit;
4eb174bee6f862 Michael Hennerich 2009-12-14  693  	}
4eb174bee6f862 Michael Hennerich 2009-12-14  694  
6c536e4ce8edd6 Michael Hennerich 2010-05-24  695  	dev_set_drvdata(dev, data);
4eb174bee6f862 Michael Hennerich 2009-12-14  696  	mutex_init(&data->update_lock);
4eb174bee6f862 Michael Hennerich 2009-12-14  697  
6c536e4ce8edd6 Michael Hennerich 2010-05-24  698  	data->bdata = *bdata;
7f3379de9cd91e Michael Hennerich 2011-11-18  699  	data->devid = devid;
6c536e4ce8edd6 Michael Hennerich 2010-05-24  700  
7f3379de9cd91e Michael Hennerich 2011-11-18  701  	data->max_pos = 1 << DPOT_MAX_POS(devid);
6c536e4ce8edd6 Michael Hennerich 2010-05-24  702  	data->rdac_mask = data->max_pos - 1;
7f3379de9cd91e Michael Hennerich 2011-11-18  703  	data->feat = DPOT_FEAT(devid);
7f3379de9cd91e Michael Hennerich 2011-11-18  704  	data->uid = DPOT_UID(devid);
7f3379de9cd91e Michael Hennerich 2011-11-18  705  	data->wipers = DPOT_WIPERS(devid);
6c536e4ce8edd6 Michael Hennerich 2010-05-24  706  
59592d0ccc0000 Michael Hennerich 2010-05-24  707  	for (i = DPOT_RDAC0; i < MAX_RDACS; i++)
6c536e4ce8edd6 Michael Hennerich 2010-05-24  708  		if (data->wipers & (1 << i)) {
6c536e4ce8edd6 Michael Hennerich 2010-05-24  709  			err = ad_dpot_add_files(dev, data->feat, i);
6c536e4ce8edd6 Michael Hennerich 2010-05-24  710  			if (err)
6c536e4ce8edd6 Michael Hennerich 2010-05-24  711  				goto exit_remove_files;
6c536e4ce8edd6 Michael Hennerich 2010-05-24  712  			/* power-up midscale */
6c536e4ce8edd6 Michael Hennerich 2010-05-24  713  			if (data->feat & F_RDACS_WONLY)
6c536e4ce8edd6 Michael Hennerich 2010-05-24  714  				data->rdac_cache[i] = data->max_pos / 2;
4eb174bee6f862 Michael Hennerich 2009-12-14  715  		}
4eb174bee6f862 Michael Hennerich 2009-12-14  716  
6c536e4ce8edd6 Michael Hennerich 2010-05-24  717  	if (data->feat & F_CMD_INC)
6c536e4ce8edd6 Michael Hennerich 2010-05-24  718  		err = sysfs_create_group(&dev->kobj, &ad525x_group_commands);
6c536e4ce8edd6 Michael Hennerich 2010-05-24  719  
4eb174bee6f862 Michael Hennerich 2009-12-14  720  	if (err) {
4eb174bee6f862 Michael Hennerich 2009-12-14  721  		dev_err(dev, "failed to register sysfs hooks\n");
45f33069c7f509 Pengpeng Hou      2026-06-15  722  		goto exit_remove_files;
4eb174bee6f862 Michael Hennerich 2009-12-14  723  	}
4eb174bee6f862 Michael Hennerich 2009-12-14  724  
4eb174bee6f862 Michael Hennerich 2009-12-14  725  	dev_info(dev, "%s %d-Position Digital Potentiometer registered\n",
7f3379de9cd91e Michael Hennerich 2011-11-18  726  		 name, data->max_pos);
4eb174bee6f862 Michael Hennerich 2009-12-14  727  
4eb174bee6f862 Michael Hennerich 2009-12-14  728  	return 0;
4eb174bee6f862 Michael Hennerich 2009-12-14  729  
6c536e4ce8edd6 Michael Hennerich 2010-05-24  730  exit_remove_files:
59592d0ccc0000 Michael Hennerich 2010-05-24  731  	for (i = DPOT_RDAC0; i < MAX_RDACS; i++)
6c536e4ce8edd6 Michael Hennerich 2010-05-24  732  		if (data->wipers & (1 << i))
6c536e4ce8edd6 Michael Hennerich 2010-05-24  733  			ad_dpot_remove_files(dev, data->feat, i);
6c536e4ce8edd6 Michael Hennerich 2010-05-24  734  
4eb174bee6f862 Michael Hennerich 2009-12-14 @735  exit_free:
4eb174bee6f862 Michael Hennerich 2009-12-14  736  	kfree(data);
6c536e4ce8edd6 Michael Hennerich 2010-05-24  737  	dev_set_drvdata(dev, NULL);
4eb174bee6f862 Michael Hennerich 2009-12-14  738  exit:
6c536e4ce8edd6 Michael Hennerich 2010-05-24  739  	dev_err(dev, "failed to create client for %s ID 0x%lX\n",
7f3379de9cd91e Michael Hennerich 2011-11-18  740  		name, devid);
4eb174bee6f862 Michael Hennerich 2009-12-14  741  	return err;
4eb174bee6f862 Michael Hennerich 2009-12-14  742  }
6c536e4ce8edd6 Michael Hennerich 2010-05-24  743  EXPORT_SYMBOL(ad_dpot_probe);
4eb174bee6f862 Michael Hennerich 2009-12-14  744  

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[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.