All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aayush Kumar <code@aayushk.dev>
To: Mark Brown <broonie@kernel.org>
Cc: David Laight <david.laight.linux@gmail.com>,
	linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org,
	Aayush Kumar <aayushkmx@gmail.com>
Subject: [PATCH v2 2/3] spi: omap2-mcspi: Use snprintf() instead of sprintf()
Date: Sat, 10 Oct 2026 14:05:03 +0530	[thread overview]
Message-ID: <20261010083504.26261-3-code@aayushk.dev> (raw)
In-Reply-To: <20261010083504.26261-1-code@aayushk.dev>

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


  parent reply	other threads:[~2026-10-10  8:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2026-10-10  8:35 ` [PATCH v2 3/3] spi: s3c64xx: Use snprintf() instead of sprintf() Aayush Kumar
2026-10-12 23:20 ` [PATCH v2 0/3] spi: use kstrtoul() and snprintf() Mark Brown

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=20261010083504.26261-3-code@aayushk.dev \
    --to=code@aayushk.dev \
    --cc=aayushkmx@gmail.com \
    --cc=broonie@kernel.org \
    --cc=david.laight.linux@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.