Skip to content

Commit 6d8bac0

Browse files
andy-shevjoergroedel
authored andcommitted
iommu/vt-d: Increase buffer size for device name
GCC is not happy with the current code, e.g.: .../iommu/intel/dmar.c:1063:9: note: ‘sprintf’ output between 6 and 15 bytes into a destination of size 13 1063 | sprintf(iommu->name, "dmar%d", iommu->seq_id); When `make W=1` is supplied, this prevents kernel building. Fix it by increasing the buffer size for device name and use sizeoF() instead of hard coded constants. Signed-off-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lu Baolu <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent 2a32309 commit 6d8bac0

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

drivers/iommu/intel/dmar.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd)
10601060
err = iommu->seq_id;
10611061
goto error;
10621062
}
1063-
sprintf(iommu->name, "dmar%d", iommu->seq_id);
1063+
snprintf(iommu->name, sizeof(iommu->name), "dmar%d", iommu->seq_id);
10641064

10651065
err = map_iommu(iommu, drhd);
10661066
if (err) {

drivers/iommu/intel/iommu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ struct intel_iommu {
720720
int msagaw; /* max sagaw of this iommu */
721721
unsigned int irq, pr_irq, perf_irq;
722722
u16 segment; /* PCI segment# */
723-
unsigned char name[13]; /* Device Name */
723+
unsigned char name[16]; /* Device Name */
724724

725725
#ifdef CONFIG_INTEL_IOMMU
726726
unsigned long *domain_ids; /* bitmap of domains */

0 commit comments

Comments
 (0)