* [PATCH v2 0/3] spi: use kstrtoul() and snprintf()
@ 2026-10-10 8:35 Aayush Kumar
2026-10-10 8:35 ` [PATCH v2 1/3] spi: tle62x0: Use kstrtoul() instead of simple_strtoul() Aayush Kumar
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Aayush Kumar @ 2026-10-10 8:35 UTC (permalink / raw)
To: Mark Brown; +Cc: David Laight, linux-spi, linux-kernel, Aayush Kumar
From: Aayush Kumar <aayushkmx@gmail.com>
Replace simple_strtoul() with kstrtoul() and sprintf() with snprintf()
in three SPI drivers.
Signed-off-by: Aayush Kumar <aayushkmx@gmail.com>
---
Changes in v2:
- Drop the two strcpy() -> strscpy() patches (David Laight).
---
Aayush Kumar (3):
spi: tle62x0: Use kstrtoul() instead of simple_strtoul()
spi: omap2-mcspi: Use snprintf() instead of sprintf()
spi: s3c64xx: Use snprintf() instead of sprintf()
drivers/spi/spi-omap2-mcspi.c | 6 ++++--
drivers/spi/spi-s3c64xx.c | 3 ++-
drivers/spi/spi-tle62x0.c | 6 +++---
3 files changed, 9 insertions(+), 6 deletions(-)
--
2.56.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 1/3] spi: tle62x0: Use kstrtoul() instead of simple_strtoul()
2026-10-10 8:35 [PATCH v2 0/3] spi: use kstrtoul() and snprintf() Aayush Kumar
@ 2026-10-10 8:35 ` Aayush Kumar
2026-10-10 8:35 ` [PATCH v2 2/3] spi: omap2-mcspi: Use snprintf() instead of sprintf() Aayush Kumar
2026-10-10 8:35 ` [PATCH v2 3/3] spi: s3c64xx: " Aayush Kumar
2 siblings, 0 replies; 4+ messages in thread
From: Aayush Kumar @ 2026-10-10 8:35 UTC (permalink / raw)
To: Mark Brown; +Cc: David Laight, linux-spi, linux-kernel, Aayush Kumar
From: Aayush Kumar <aayushkmx@gmail.com>
Use the recommended kstrtoul() instead of the deprecated
simple_strtoul(). Check the return value and reject invalid values.
Signed-off-by: Aayush Kumar <aayushkmx@gmail.com>
---
drivers/spi/spi-tle62x0.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/spi/spi-tle62x0.c b/drivers/spi/spi-tle62x0.c
index dd8bfb3f3..986d78ab4 100644
--- a/drivers/spi/spi-tle62x0.c
+++ b/drivers/spi/spi-tle62x0.c
@@ -151,10 +151,10 @@ static ssize_t tle62x0_gpio_store(struct device *dev,
struct tle62x0_state *st = dev_get_drvdata(dev);
int gpio_num = to_gpio_num(attr);
unsigned long val;
- char *endp;
+ int ret;
- val = simple_strtoul(buf, &endp, 0);
- if (buf == endp)
+ ret = kstrtoul(buf, 0, &val);
+ if (ret)
return -EINVAL;
dev_dbg(dev, "setting gpio %d to %ld\n", gpio_num, val);
--
2.56.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 2/3] spi: omap2-mcspi: Use snprintf() instead of sprintf()
2026-10-10 8:35 [PATCH v2 0/3] spi: use kstrtoul() and snprintf() Aayush Kumar
2026-10-10 8:35 ` [PATCH v2 1/3] spi: tle62x0: Use kstrtoul() instead of simple_strtoul() Aayush Kumar
@ 2026-10-10 8:35 ` Aayush Kumar
2026-10-10 8:35 ` [PATCH v2 3/3] spi: s3c64xx: " Aayush Kumar
2 siblings, 0 replies; 4+ messages in thread
From: Aayush Kumar @ 2026-10-10 8:35 UTC (permalink / raw)
To: Mark Brown; +Cc: David Laight, linux-spi, linux-kernel, Aayush Kumar
From: Aayush Kumar <aayushkmx@gmail.com>
Use snprintf() instead of sprintf() to avoid potential buffer
overflows when formatting DMA channel names.
Signed-off-by: Aayush Kumar <aayushkmx@gmail.com>
---
drivers/spi/spi-omap2-mcspi.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index a3355147f..311ee0ca9 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1544,8 +1544,10 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
return -ENOMEM;
for (i = 0; i < ctlr->num_chipselect; i++) {
- sprintf(mcspi->dma_channels[i].dma_rx_ch_name, "rx%d", i);
- sprintf(mcspi->dma_channels[i].dma_tx_ch_name, "tx%d", i);
+ snprintf(mcspi->dma_channels[i].dma_rx_ch_name,
+ sizeof(mcspi->dma_channels[i].dma_rx_ch_name), "rx%d", i);
+ snprintf(mcspi->dma_channels[i].dma_tx_ch_name,
+ sizeof(mcspi->dma_channels[i].dma_tx_ch_name), "tx%d", i);
status = omap2_mcspi_request_dma(mcspi,
&mcspi->dma_channels[i]);
--
2.56.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 3/3] spi: s3c64xx: Use snprintf() instead of sprintf()
2026-10-10 8:35 [PATCH v2 0/3] spi: use kstrtoul() and snprintf() Aayush Kumar
2026-10-10 8:35 ` [PATCH v2 1/3] spi: tle62x0: Use kstrtoul() instead of simple_strtoul() Aayush Kumar
2026-10-10 8:35 ` [PATCH v2 2/3] spi: omap2-mcspi: Use snprintf() instead of sprintf() Aayush Kumar
@ 2026-10-10 8:35 ` Aayush Kumar
2 siblings, 0 replies; 4+ messages in thread
From: Aayush Kumar @ 2026-10-10 8:35 UTC (permalink / raw)
To: Mark Brown; +Cc: David Laight, linux-spi, linux-kernel, Aayush Kumar
From: Aayush Kumar <aayushkmx@gmail.com>
Use snprintf() instead of sprintf() to avoid potential buffer
overflows when formatting the clock name.
Signed-off-by: Aayush Kumar <aayushkmx@gmail.com>
---
drivers/spi/spi-s3c64xx.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index 8d4120cf9..8195bf376 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -1331,7 +1331,8 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
return dev_err_probe(&pdev->dev, PTR_ERR(sdd->clk),
"Unable to acquire clock 'spi'\n");
- sprintf(clk_name, "spi_busclk%d", sci->src_clk_nr);
+ snprintf(clk_name, sizeof(clk_name), "spi_busclk%d",
+ sci->src_clk_nr);
sdd->src_clk = devm_clk_get_enabled(&pdev->dev, clk_name);
if (IS_ERR(sdd->src_clk))
return dev_err_probe(&pdev->dev, PTR_ERR(sdd->src_clk),
--
2.56.0
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-10-10 8:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-10 8:35 [PATCH v2 0/3] spi: use kstrtoul() and snprintf() Aayush Kumar
2026-10-10 8:35 ` [PATCH v2 1/3] spi: tle62x0: Use kstrtoul() instead of simple_strtoul() Aayush Kumar
2026-10-10 8:35 ` [PATCH v2 2/3] spi: omap2-mcspi: Use snprintf() instead of sprintf() Aayush Kumar
2026-10-10 8:35 ` [PATCH v2 3/3] spi: s3c64xx: " Aayush Kumar
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®