Skip to content

Commit db184a1

Browse files
nicolincwilldeacon
authored andcommitted
iommu/tegra241-cmdqv: Fix -Wformat-truncation warnings in lvcmdq_error_header
Kernel test robot reported a few trucation warnings at the snprintf: drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c: In function ‘tegra241_vintf_free_lvcmdq’: drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c:239:56: warning: ‘%u’ directive output may be truncated writing between 1 and 5 bytes into a region of size between 3 and 11 [-Wformat-truncation=] 239 | snprintf(header, hlen, "VINTF%u: VCMDQ%u/LVCMDQ%u: ", | ^~ drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c:239:32: note: directive argument in the range [0, 65535] 239 | snprintf(header, hlen, "VINTF%u: VCMDQ%u/LVCMDQ%u: ", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c:239:9: note: ‘snprintf’ output between 25 and 37 bytes into a destination of size 32 239 | snprintf(header, hlen, "VINTF%u: VCMDQ%u/LVCMDQ%u: ", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 240 | vcmdq->vintf->idx, vcmdq->idx, vcmdq->lidx); Fix by bumping up the size of the header to hold more characters. Fixes: 918eb5c ("iommu/arm-smmu-v3: Add in-kernel support for NVIDIA Tegra241 (Grace) CMDQV") Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202409020406.7ed5uojF-lkp@intel.com/ Signed-off-by: Nicolin Chen <nicolinc@nvidia.com> Link: https://lore.kernel.org/r/20240902055745.629456-1-nicolinc@nvidia.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent 070e326 commit db184a1

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ static inline int vintf_write_config(struct tegra241_vintf *vintf, u32 regval)
233233
static inline char *lvcmdq_error_header(struct tegra241_vcmdq *vcmdq,
234234
char *header, int hlen)
235235
{
236-
WARN_ON(hlen < 32);
236+
WARN_ON(hlen < 64);
237237
if (WARN_ON(!vcmdq->vintf))
238238
return "";
239239
snprintf(header, hlen, "VINTF%u: VCMDQ%u/LVCMDQ%u: ",
@@ -243,7 +243,7 @@ static inline char *lvcmdq_error_header(struct tegra241_vcmdq *vcmdq,
243243

244244
static inline int vcmdq_write_config(struct tegra241_vcmdq *vcmdq, u32 regval)
245245
{
246-
char header[32], *h = lvcmdq_error_header(vcmdq, header, 32);
246+
char header[64], *h = lvcmdq_error_header(vcmdq, header, 64);
247247

248248
return tegra241_cmdqv_write_config(vcmdq->cmdqv,
249249
REG_VCMDQ_PAGE0(vcmdq, CONFIG),
@@ -354,7 +354,7 @@ tegra241_cmdqv_get_cmdq(struct arm_smmu_device *smmu,
354354

355355
static void tegra241_vcmdq_hw_deinit(struct tegra241_vcmdq *vcmdq)
356356
{
357-
char header[32], *h = lvcmdq_error_header(vcmdq, header, 32);
357+
char header[64], *h = lvcmdq_error_header(vcmdq, header, 64);
358358
u32 gerrorn, gerror;
359359

360360
if (vcmdq_write_config(vcmdq, 0)) {
@@ -382,7 +382,7 @@ static void tegra241_vcmdq_hw_deinit(struct tegra241_vcmdq *vcmdq)
382382

383383
static int tegra241_vcmdq_hw_init(struct tegra241_vcmdq *vcmdq)
384384
{
385-
char header[32], *h = lvcmdq_error_header(vcmdq, header, 32);
385+
char header[64], *h = lvcmdq_error_header(vcmdq, header, 64);
386386
int ret;
387387

388388
/* Reset VCMDQ */
@@ -555,13 +555,13 @@ static int tegra241_vintf_init_lvcmdq(struct tegra241_vintf *vintf, u16 lidx,
555555
static void tegra241_vintf_free_lvcmdq(struct tegra241_vintf *vintf, u16 lidx)
556556
{
557557
struct tegra241_vcmdq *vcmdq = vintf->lvcmdqs[lidx];
558-
char header[32];
558+
char header[64];
559559

560560
tegra241_vcmdq_free_smmu_cmdq(vcmdq);
561561
tegra241_vintf_deinit_lvcmdq(vintf, lidx);
562562

563563
dev_dbg(vintf->cmdqv->dev,
564-
"%sdeallocated\n", lvcmdq_error_header(vcmdq, header, 32));
564+
"%sdeallocated\n", lvcmdq_error_header(vcmdq, header, 64));
565565
kfree(vcmdq);
566566
}
567567

@@ -570,7 +570,7 @@ tegra241_vintf_alloc_lvcmdq(struct tegra241_vintf *vintf, u16 lidx)
570570
{
571571
struct tegra241_cmdqv *cmdqv = vintf->cmdqv;
572572
struct tegra241_vcmdq *vcmdq;
573-
char header[32];
573+
char header[64];
574574
int ret;
575575

576576
vcmdq = kzalloc(sizeof(*vcmdq), GFP_KERNEL);
@@ -587,7 +587,7 @@ tegra241_vintf_alloc_lvcmdq(struct tegra241_vintf *vintf, u16 lidx)
587587
goto deinit_lvcmdq;
588588

589589
dev_dbg(cmdqv->dev,
590-
"%sallocated\n", lvcmdq_error_header(vcmdq, header, 32));
590+
"%sallocated\n", lvcmdq_error_header(vcmdq, header, 64));
591591
return vcmdq;
592592

593593
deinit_lvcmdq:

0 commit comments

Comments
 (0)