tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 06dc10eae55b5ceabfef287a7e5f16ceea204aa0
commit: a7cffa11fa9232eabf0c4f441dc53002978ab526 memory: tegra: Add memory controller channels support
date: 1 year, 5 months ago
config: arm64-randconfig-r036-20230512 (https://download.01.org/0day-ci/archive/20231018/[email protected]/config)
compiler: aarch64-linux-gcc (GCC) 11.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231018/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
drivers/memory/tegra/tegra186.c: In function 'tegra186_mc_probe':
>> drivers/memory/tegra/tegra186.c:74:49: warning: '%u' directive output may be truncated writing between 1 and 10 bytes into a region of size 6 [-Wformat-truncation=]
74 | snprintf(name, sizeof(name), "ch%u", i);
| ^~
drivers/memory/tegra/tegra186.c:74:46: note: directive argument in the range [0, 4294967294]
74 | snprintf(name, sizeof(name), "ch%u", i);
| ^~~~~~
drivers/memory/tegra/tegra186.c:74:17: note: 'snprintf' output between 4 and 13 bytes into a destination of size 8
74 | snprintf(name, sizeof(name), "ch%u", i);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vim +74 drivers/memory/tegra/tegra186.c
48
49 static int tegra186_mc_probe(struct tegra_mc *mc)
50 {
51 struct platform_device *pdev = to_platform_device(mc->dev);
52 unsigned int i;
53 char name[8];
54 int err;
55
56 mc->bcast_ch_regs = devm_platform_ioremap_resource_byname(pdev, "broadcast");
57 if (IS_ERR(mc->bcast_ch_regs)) {
58 if (PTR_ERR(mc->bcast_ch_regs) == -EINVAL) {
59 dev_warn(&pdev->dev,
60 "Broadcast channel is missing, please update your device-tree\n");
61 mc->bcast_ch_regs = NULL;
62 goto populate;
63 }
64
65 return PTR_ERR(mc->bcast_ch_regs);
66 }
67
68 mc->ch_regs = devm_kcalloc(mc->dev, mc->soc->num_channels, sizeof(*mc->ch_regs),
69 GFP_KERNEL);
70 if (!mc->ch_regs)
71 return -ENOMEM;
72
73 for (i = 0; i < mc->soc->num_channels; i++) {
> 74 snprintf(name, sizeof(name), "ch%u", i);
75
76 mc->ch_regs[i] = devm_platform_ioremap_resource_byname(pdev, name);
77 if (IS_ERR(mc->ch_regs[i]))
78 return PTR_ERR(mc->ch_regs[i]);
79 }
80
81 populate:
82 err = of_platform_populate(mc->dev->of_node, NULL, NULL, mc->dev);
83 if (err < 0)
84 return err;
85
86 tegra186_mc_program_sid(mc);
87
88 return 0;
89 }
90
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
On 18/10/2023 14:32, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: 06dc10eae55b5ceabfef287a7e5f16ceea204aa0
> commit: a7cffa11fa9232eabf0c4f441dc53002978ab526 memory: tegra: Add memory controller channels support
> date: 1 year, 5 months ago
> config: arm64-randconfig-r036-20230512 (https://download.01.org/0day-ci/archive/20231018/[email protected]/config)
> compiler: aarch64-linux-gcc (GCC) 11.3.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231018/[email protected]/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <[email protected]>
> | Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
>
> All warnings (new ones prefixed by >>):
Ashish,
Are you planning to respond to this?
Best regards,
Krzysztof
On 10/19/2023 7:06 PM, Krzysztof Kozlowski wrote:
> External email: Use caution opening links or attachments
>
>
> On 18/10/2023 14:32, kernel test robot wrote:
>> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
>> head: 06dc10eae55b5ceabfef287a7e5f16ceea204aa0
>> commit: a7cffa11fa9232eabf0c4f441dc53002978ab526 memory: tegra: Add memory controller channels support
>> date: 1 year, 5 months ago
>> config: arm64-randconfig-r036-20230512 (https://download.01.org/0day-ci/archive/20231018/[email protected]/config)
>> compiler: aarch64-linux-gcc (GCC) 11.3.0
>> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231018/[email protected]/reproduce)
>>
>> If you fix the issue in a separate patch/commit (i.e. not just a new version of
>> the same patch/commit), kindly add following tags
>> | Reported-by: kernel test robot <[email protected]>
>> | Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
>>
>> All warnings (new ones prefixed by >>):
> Ashish,
>
> Are you planning to respond to this?
>
> Best regards,
> Krzysztof
Hi Krzysztof,
The value of mc->soc->num_channels is not more that 16. The number of
characters written in 'name' variable won't be more than 4 which is less
than buffer size of 8 bytes. So, can we ignore this warning?
If not, then I can fix this with a patch to check the return value of
snprintf and compare that with size of buffer 'name'. Something like:
- snprintf(name, sizeof(name), "ch%u", i);
+ int n = snprintf(name, sizeof(name), "ch%u", i);
+
+ if (n < 0) {
+ dev_err(&pdev->dev, "snprintf failed\n");
+ return -EFAULT;
+ }
+ if ((size_t)n > sizeof(name)) {
+ dev_err(&pdev->dev, "snprintf output is
truncated\n");
+ return -EFAULT;
+ }
Thanks,
Ashish Mhetre