[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <880aeea52f3bdde5e3e8843bbedb7fd068a58be2.1698565938.git.christophe.jaillet@wanadoo.fr>
Date: Sun, 29 Oct 2023 08:52:36 +0100
From: Christophe JAILLET <christophe.jaillet@...adoo.fr>
To: Nishanth Menon <nm@...com>, Tero Kristo <kristo@...nel.org>,
Santosh Shilimkar <ssantosh@...nel.org>
Cc: linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
Christophe JAILLET <christophe.jaillet@...adoo.fr>,
Tero Kristo <t-kristo@...com>,
linux-arm-kernel@...ts.infradead.org
Subject: [PATCH] firmware: ti_sci: Fix an off-by-one in ti_sci_debugfs_create()
The ending NULL is not taken into account by strncat(), so switch to
strlcat() to correctly compute the size of the available memory when
building 'debug_name'.
Because of the difference in the return type between strncat() and
strlcat(), some code shuffling is needed.
Fixes: aa276781a64a ("firmware: Add basic support for TI System Control Interface (TI-SCI) protocol")
Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
---
drivers/firmware/ti_sci.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
index 7041befc756a..1036c6b0f3eb 100644
--- a/drivers/firmware/ti_sci.c
+++ b/drivers/firmware/ti_sci.c
@@ -181,10 +181,9 @@ static int ti_sci_debugfs_create(struct platform_device *pdev,
/* Setup NULL termination */
info->debug_buffer[info->debug_region_size] = 0;
- info->d = debugfs_create_file(strncat(debug_name, dev_name(dev),
- sizeof(debug_name) -
- sizeof("ti_sci_debug@")),
- 0444, NULL, info, &ti_sci_debug_fops);
+ strlcat(debug_name, dev_name(dev), sizeof(debug_name));
+ info->d = debugfs_create_file(debug_name, 0444, NULL, info,
+ &ti_sci_debug_fops);
if (IS_ERR(info->d))
return PTR_ERR(info->d);
--
2.34.1
Powered by blists - more mailing lists