From: Daniel Golle <daniel@makrotopia.org>
To: Miquel Raynal <miquel.raynal@bootlin.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] nvmem: core: clear sysfs attributes for each NVMEM device
Date: Tue, 18 Jul 2023 14:55:31 +0100 [thread overview]
Message-ID: <ZLaZ03PzkbPNJQ3b@makrotopia.org> (raw)
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")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
drivers/nvmem/core.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 6c04a9cf6919f..70e951088826d 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -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,
--
2.41.0
next reply other threads:[~2023-07-18 13:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-18 13:55 Daniel Golle [this message]
2023-07-18 14:42 ` Greg Kroah-Hartman
2023-07-18 14:43 ` Greg Kroah-Hartman
2023-07-18 14:55 ` Srinivas Kandagatla
2023-07-18 15:29 ` Daniel Golle
2023-07-19 8:13 ` Miquel Raynal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZLaZ03PzkbPNJQ3b@makrotopia.org \
--to=daniel@makrotopia.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miquel.raynal@bootlin.com \
--cc=srinivas.kandagatla@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®