nvmem: core: clear sysfs attributes for each NVMEM device
PATCH 1/2 nvmem: core: clear sysfs attributes for each NVMEM device
Set nvmem_cells_group.bin_attrs to NULL in case of an NVMEM device not having any cells in order to make sure sysfs attributes of a previously registered NVMEM device are not accidentally reused for a follow-up device which doesn't have any cells.
--- drivers/nvmem/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/nvmem/core.c +3 -2
@@ -458,9 +458,10 @@ static int nvmem_populate_sysfs_cells(struct nvmem_device *nvmem)mutex_lock (&nvmem_mutex); -if (list_empty (&nvmem->cells)) +if (list_empty (&nvmem->cells)) { + nvmem_cells_group.bin_attrs =NULL ; goto unlock_mutex; - + }/* Allocate an array of attributes with a sentinel */ ncells =list_count_nodes (&nvmem->cells); cells_attrs = devm_kcalloc(&nvmem->dev, ncells + 1,
Signature · 1 line
2.41.0
Quoted 6 lines · Daniel Golle
Set nvmem_cells_group.bin_attrs to NULL in case of an NVMEM device not having any cells in order to make sure sysfs attributes of a previously registered NVMEM device are not accidentally reused for a follow-up device which doesn't have any cells.
Fixes 757f8b3835c9 ("nvmem: core: Expose cells through sysfs")
Where is this git commit id? I don't see it in Linus's tree.
Quoted 4 lines
Signed-off-by Daniel Golle <[email protected]>--- drivers/nvmem/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Your patches were not threaded/attached to each other either, so our tools can't take them together. Can you fix that up and use 'git send-email' or other such tools to have this show up properly when you send a v2?
thanks,
greg k-h
Quoted 4 lines · Daniel Golle
Set nvmem_cells_group.bin_attrs to NULL in case of an NVMEM device not having any cells in order to make sure sysfs attributes of a previously registered NVMEM device are not accidentally reused for a follow-up device which doesn't have any cells.
Wait, attributes and devices should NEVER be reused, how is that happening here?
And just setting the attribute field to NULL doesn't free or clean up anything, right? Did memory just leak with this?
confused,
greg k-h
HI Daniel,
Quoted 6 lines · Daniel Golle
Set nvmem_cells_group.bin_attrs to NULL in case of an NVMEM device not having any cells in order to make sure sysfs attributes of a previously registered NVMEM device are not accidentally reused for a follow-up device which doesn't have any cells.
Fixes 757f8b3835c9 ("nvmem: core: Expose cells through sysfs")
These patches are dropped out of nvmem next branch as it was breaking some existing users.
--srini
Quoted 22 lines
Signed-off-by Daniel Golle <[email protected]>--- drivers/nvmem/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/nvmem/core.c +3
-2@@ -458,9 +458,10 @@ static int nvmem_populate_sysfs_cells(struct nvmem_device *nvmem)mutex_lock (&nvmem_mutex); -if (list_empty (&nvmem->cells)) +if (list_empty (&nvmem->cells)) { + nvmem_cells_group.bin_attrs =NULL ; goto unlock_mutex; - + }/* Allocate an array of attributes with a sentinel */ ncells =list_count_nodes (&nvmem->cells); cells_attrs = devm_kcalloc(&nvmem->dev, ncells + 1,
Quoted 8 lines · Srinivas Kandagatla
HI Daniel,
Quoted 5 lines · Daniel Golle
Set nvmem_cells_group.bin_attrs to NULL in case of an NVMEM device not having any cells in order to make sure sysfs attributes of a previously registered NVMEM device are not accidentally reused for a follow-up device which doesn't have any cells.
Quoted 4 lines
Quoted 1 line
Fixes 757f8b3835c9 ("nvmem: core: Expose cells through sysfs")These patches are dropped out of nvmem next branch as it was breaking some existing users.
Ok. I've encountered those commits in linux-next and can confirm that they were definitely also breaking things here, hence my patches at least partially fixing that.
I agree that reverting them for now and reworking them seems to be the better option in this case, hence my patches won't be needed as such.
Quoted 23 lines
--srini
Quoted 20 lines
Signed-off-by Daniel Golle <[email protected]>--- drivers/nvmem/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/nvmem/core.c +3
-2@@ -458,9 +458,10 @@ static int nvmem_populate_sysfs_cells(struct nvmem_device *nvmem)mutex_lock (&nvmem_mutex); -if (list_empty (&nvmem->cells)) +if (list_empty (&nvmem->cells)) { + nvmem_cells_group.bin_attrs =NULL ; goto unlock_mutex; - + }/* Allocate an array of attributes with a sentinel */ ncells =list_count_nodes (&nvmem->cells); cells_attrs = devm_kcalloc(&nvmem->dev, ncells + 1,
Hi Daniel,
[email protected] wrote on Tue, 18 Jul 2023 16:29:07 +0100:
Quoted 14 lines · Srinivas Kandagatla
Quoted 8 lines
HI Daniel,
Quoted 5 lines · Daniel Golle
Set nvmem_cells_group.bin_attrs to NULL in case of an NVMEM device not having any cells in order to make sure sysfs attributes of a previously registered NVMEM device are not accidentally reused for a follow-up device which doesn't have any cells.
Quoted 4 lines
Quoted 1 line
Fixes 757f8b3835c9 ("nvmem: core: Expose cells through sysfs")These patches are dropped out of nvmem next branch as it was breaking some existing users.
Quoted 6 lines
Ok. I've encountered those commits in linux-next and can confirm that they were definitely also breaking things here, hence my patches at least partially fixing that.
I agree that reverting them for now and reworking them seems to be the better option in this case, hence my patches won't be needed as such.
Quite the opposite, on my setup I don't have any breakage but as you already fixed the cell name issue (also reported by Chen-yu), if you agree, I will include these fixes (or an improved version) in my next proposal.
Thanks,
Miquèl