diff mbox series

[2/7] media: cadence: increase buffer size in csi2tx_get_resources()

Message ID 20230922105036.3148784-3-hverkuil-cisco@xs4all.nl
State Superseded
Headers show
Series media: string truncate warnings: fix low-hanging fruit | expand

Commit Message

Hans Verkuil Sept. 22, 2023, 10:50 a.m. UTC
Fixes this compiler warning:

drivers/media/platform/cadence/cdns-csi2tx.c: In function 'csi2tx_get_resources':
drivers/media/platform/cadence/cdns-csi2tx.c:485:63: warning: '%u' directive output may be truncated writing between 1 and 10 bytes into a region of size 8 [-Wformat-truncation=]
  485 |                 snprintf(clk_name, sizeof(clk_name), "pixel_if%u_clk", i);
      |                                                               ^~
drivers/media/platform/cadence/cdns-csi2tx.c:485:54: note: directive argument in the range [0, 4294967294]
  485 |                 snprintf(clk_name, sizeof(clk_name), "pixel_if%u_clk", i);
      |                                                      ^~~~~~~~~~~~~~~~
drivers/media/platform/cadence/cdns-csi2tx.c:485:17: note: 'snprintf' output between 14 and 23 bytes into a destination of size 16
  485 |                 snprintf(clk_name, sizeof(clk_name), "pixel_if%u_clk", i);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: Maxime Ripard <mripard@kernel.org>
---
 drivers/media/platform/cadence/cdns-csi2tx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Maxime Ripard Sept. 22, 2023, 11:22 a.m. UTC | #1
On Fri, 22 Sep 2023 12:50:31 +0200, Hans Verkuil wrote:
> Fixes this compiler warning:
> 
> drivers/media/platform/cadence/cdns-csi2tx.c: In function 'csi2tx_get_resources':
> drivers/media/platform/cadence/cdns-csi2tx.c:485:63: warning: '%u' directive output may be truncated writing between 1 and 10 bytes into a region of size 8 [-Wformat-truncation=]
>   485 |                 snprintf(clk_name, sizeof(clk_name), "pixel_if%u_clk", i);
> 
> [ ... ]

Acked-by: Maxime Ripard <mripard@kernel.org>

Thanks!
Maxime
diff mbox series

Patch

diff --git a/drivers/media/platform/cadence/cdns-csi2tx.c b/drivers/media/platform/cadence/cdns-csi2tx.c
index 1e0400b7803e..cbbb77520112 100644
--- a/drivers/media/platform/cadence/cdns-csi2tx.c
+++ b/drivers/media/platform/cadence/cdns-csi2tx.c
@@ -480,7 +480,7 @@  static int csi2tx_get_resources(struct csi2tx_priv *csi2tx,
 	csi2tx->has_internal_dphy = !!(dev_cfg & CSI2TX_DEVICE_CONFIG_HAS_DPHY);
 
 	for (i = 0; i < csi2tx->max_streams; i++) {
-		char clk_name[16];
+		char clk_name[23];
 
 		snprintf(clk_name, sizeof(clk_name), "pixel_if%u_clk", i);
 		csi2tx->pixel_clk[i] = devm_clk_get(&pdev->dev, clk_name);