From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: "Krzysztof Wilczyński" <kw@linux.com>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Logan Gunthorpe" <logang@deltatee.com>,
"Sasha Levin" <sashal@kernel.org>
Subject: [PATCH 5.10.y 1/3] PCI/sysfs: Rely on lengths from scnprintf(), dsm_label_utf16s_to_utf8s()
Date: Wed, 9 Sep 2026 10:53:30 -0400 [thread overview]
Message-ID: <20260909145332.2696721-1-sashal@kernel.org> (raw)
In-Reply-To: <2026090357-freeness-pelvis-28aa@gregkh>
From: Krzysztof Wilczyński <kw@linux.com>
[ Upstream commit 316ae33051215f92c72fe13bc1bfc4e513a26700 ]
scnprintf() returns the number of bytes written into the buffer. Change
dsm_label_utf16s_to_utf8s() to do the same. Rely on those values instead
of using strlen() to compute the buffer length.
No functional change intended.
[bhelgaas: reorder patch in series, len++ to include newline added by
dsm_label_utf16s_to_utf8s(), commit log]
Link: https://lore.kernel.org/r/20210603000112.703037-3-kw@linux.com
Signed-off-by: Krzysztof Wilczyński <kw@linux.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
Stable-dep-of: dcc5bec09e23 ("PCI: Allow per function PCI slots to fix slot reset on s390")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/pci/pci-label.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/pci/pci-label.c b/drivers/pci/pci-label.c
index 6c406453b49f4..a24d28414f3a2 100644
--- a/drivers/pci/pci-label.c
+++ b/drivers/pci/pci-label.c
@@ -154,14 +154,17 @@ enum acpi_attr_enum {
ACPI_ATTR_INDEX_SHOW,
};
-static void dsm_label_utf16s_to_utf8s(union acpi_object *obj, char *buf)
+static int dsm_label_utf16s_to_utf8s(union acpi_object *obj, char *buf)
{
int len;
+
len = utf16s_to_utf8s((const wchar_t *)obj->buffer.pointer,
obj->buffer.length,
UTF16_LITTLE_ENDIAN,
buf, PAGE_SIZE - 1);
- buf[len] = '\n';
+ buf[len++] = '\n';
+
+ return len;
}
static int dsm_get_label(struct device *dev, char *buf,
@@ -169,7 +172,7 @@ static int dsm_get_label(struct device *dev, char *buf,
{
acpi_handle handle;
union acpi_object *obj, *tmp;
- int len = -1;
+ int len = 0;
handle = ACPI_HANDLE(dev);
if (!handle)
@@ -191,20 +194,19 @@ static int dsm_get_label(struct device *dev, char *buf,
* this entry must return a null string.
*/
if (attr == ACPI_ATTR_INDEX_SHOW) {
- scnprintf(buf, PAGE_SIZE, "%llu\n", tmp->integer.value);
+ len = scnprintf(buf, PAGE_SIZE, "%llu\n", tmp->integer.value);
} else if (attr == ACPI_ATTR_LABEL_SHOW) {
if (tmp[1].type == ACPI_TYPE_STRING)
- scnprintf(buf, PAGE_SIZE, "%s\n",
+ len = scnprintf(buf, PAGE_SIZE, "%s\n",
tmp[1].string.pointer);
else if (tmp[1].type == ACPI_TYPE_BUFFER)
- dsm_label_utf16s_to_utf8s(tmp + 1, buf);
+ len = dsm_label_utf16s_to_utf8s(tmp + 1, buf);
}
- len = strlen(buf) > 0 ? strlen(buf) : -1;
}
ACPI_FREE(obj);
- return len;
+ return len > 0 ? len : -1;
}
static bool device_has_dsm(struct device *dev)
--
2.53.0
next prev parent reply other threads:[~2026-09-09 14:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 14:42 FAILED: patch "[PATCH] PCI: Allow per function PCI slots to fix slot reset on s390" failed to apply to 5.10-stable tree gregkh
2026-09-09 14:53 ` Sasha Levin [this message]
2026-09-09 14:53 ` [PATCH 5.10.y 2/3] PCI: Introduce PCI_SLOT_PLACEHOLDER constant for slot_nr placeholder value Sasha Levin
2026-09-09 14:53 ` [PATCH 5.10.y 3/3] PCI: Allow per function PCI slots to fix slot reset on s390 Sasha Levin
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=20260909145332.2696721-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=bhelgaas@google.com \
--cc=kw@linux.com \
--cc=logang@deltatee.com \
--cc=stable@vger.kernel.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