Messages in this thread | | | Date | Wed, 23 Nov 2022 17:56:59 +0800 | Subject | Re: [PATCH] regulator: core: fix kernfs complain in destroy_regulator() | From | Zeng Heng <> |
| |
+cc linux-kernel-mail-list
On 2022/11/23 17:15, Zeng Heng wrote: > Creating sysfs entry failed is non-fatal exception any more since from > commit <222cc7b1cefb>, so when try to remove the entry in > _regulator_put(), it had better to check kernfs_node before calling > sysfs_remove_link(). > > Otherwise, kernfs would complain warning as below: > > kernfs: can not remove 'rt5759_buck_consumer-default', no directory > WARNING: CPU: 2 PID: 3383 at fs/kernfs/dir.c:1615 kernfs_remove_by_name_ns+0xd5/0xe0 > Call Trace: > _regulator_put.part.0+0xca/0x2f0 > regulator_put+0x37/0x50 > release_nodes+0x6a/0xa0 > devres_release_all+0xfe/0x150 > device_unbind_cleanup+0x19/0xd0 > device_release_driver_internal+0x17d/0x210 > bus_remove_device+0x1bd/0x240 > device_del+0x356/0x780 > platform_device_del.part.0+0x1a/0x100 > platform_device_unregister+0x29/0x50 > > Fixes: 222cc7b1cefb ("regulator: core: Allow multiple requests of a single supply mapping") > Signed-off-by: Zeng Heng <zengheng4@huawei.com> > --- > drivers/regulator/core.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c > index 77126cb1ae8c..ca3981681bbf 100644 > --- a/drivers/regulator/core.c > +++ b/drivers/regulator/core.c > @@ -2294,7 +2294,8 @@ static void destroy_regulator(struct regulator *regulator) > device_link_remove(regulator->dev, &rdev->dev); > > /* remove any sysfs entries */ > - sysfs_remove_link(&rdev->dev.kobj, regulator->supply_name); > + if (rdev->dev.kobj.sd) > + sysfs_remove_link(&rdev->dev.kobj, regulator->supply_name); > } > > regulator_lock(rdev);
| |