From: Frank van der Linden <fvdl@google.com>
To: kernel test robot <lkp@intel.com>
Cc: oe-kbuild-all@lists.linux.dev,
Andrew Morton <akpm@linux-foundation.org>,
Linux Memory Management List <linux-mm@kvack.org>
Subject: Re: [akpm-mm:mm-unstable 61/88] mm/cma_debug.c:189:55: warning: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 3
Date: Fri, 31 Jan 2025 09:05:19 -0800 [thread overview]
Message-ID: <CAPTztWb6kO_OkoNz6xHKa-F0VFawCOPc2BO34cRzidnVYCj1ow@mail.gmail.com> (raw)
In-Reply-To: <202501311125.wbG1DN2B-lkp@intel.com>
On Thu, Jan 30, 2025 at 7:13 PM kernel test robot <lkp@intel.com> wrote:
>
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-unstable
> head: 495206a68b359eb6117d0860861578113bbb94e7
> commit: 77cbd63e91fa6c5f6157a30e61a380b6c47c1443 [61/88] mm, cma: support multiple contiguous ranges, if requested
> config: x86_64-buildonly-randconfig-003-20250131 (https://download.01.org/0day-ci/archive/20250131/202501311125.wbG1DN2B-lkp@intel.com/config)
> compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250131/202501311125.wbG1DN2B-lkp@intel.com/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 <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202501311125.wbG1DN2B-lkp@intel.com/
>
> All warnings (new ones prefixed by >>):
>
> mm/cma_debug.c: In function 'cma_debugfs_add_one':
> >> mm/cma_debug.c:189:55: warning: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 3 [-Wformat-truncation=]
> 189 | snprintf(rdirname, sizeof(rdirname), "%d", r);
> | ^~
> mm/cma_debug.c:189:54: note: directive argument in the range [-2147483644, 2147483646]
> 189 | snprintf(rdirname, sizeof(rdirname), "%d", r);
> | ^~~~
> mm/cma_debug.c:189:17: note: 'snprintf' output between 2 and 12 bytes into a destination of size 3
> 189 | snprintf(rdirname, sizeof(rdirname), "%d", r);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
> vim +189 mm/cma_debug.c
>
> 168
> 169 static void cma_debugfs_add_one(struct cma *cma, struct dentry *root_dentry)
> 170 {
> 171 struct dentry *tmp, *dir, *rangedir;
> 172 int r;
> 173 char rdirname[3];
> 174 struct cma_memrange *cmr;
> 175
> 176 tmp = debugfs_create_dir(cma->name, root_dentry);
> 177
> 178 debugfs_create_file("alloc", 0200, tmp, cma, &cma_alloc_fops);
> 179 debugfs_create_file("free", 0200, tmp, cma, &cma_free_fops);
> 180 debugfs_create_file("count", 0444, tmp, &cma->count, &cma_debugfs_fops);
> 181 debugfs_create_file("order_per_bit", 0444, tmp,
> 182 &cma->order_per_bit, &cma_debugfs_fops);
> 183 debugfs_create_file("used", 0444, tmp, cma, &cma_used_fops);
> 184 debugfs_create_file("maxchunk", 0444, tmp, cma, &cma_maxchunk_fops);
> 185
> 186 rangedir = debugfs_create_dir("ranges", tmp);
> 187 for (r = 0; r < cma->nranges; r++) {
> 188 cmr = &cma->ranges[r];
> > 189 snprintf(rdirname, sizeof(rdirname), "%d", r);
> 190 dir = debugfs_create_dir(rdirname, rangedir);
> 191 debugfs_create_file("base_pfn", 0444, dir,
> 192 &cmr->base_pfn, &cma_debugfs_fops);
> 193 cmr->dfs_bitmap.array = (u32 *)cmr->bitmap;
> 194 cmr->dfs_bitmap.n_elements =
> 195 DIV_ROUND_UP(cma_bitmap_maxno(cma, cmr),
> 196 BITS_PER_BYTE * sizeof(u32));
> 197 debugfs_create_u32_array("bitmap", 0444, dir,
> 198 &cmr->dfs_bitmap);
> 199 }
> 200
> 201 /*
> 202 * Backward compatible symlinks to range 0 for base_pfn and bitmap.
> 203 */
> 204 debugfs_create_symlink("base_pfn", tmp, "ranges/0/base_pfn");
> 205 debugfs_create_symlink("bitmap", tmp, "ranges/0/bitmap");
> 206 }
> 207
>
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki
CMA_MAX_RANGES is 8, and it's an snprintf, so no, it will never use
more than 1 digit. But, I can bump up the size of the buffer is that
makes the compiler happier in this case. I'll do that.
- Frank
prev parent reply other threads:[~2025-01-31 17:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-31 3:12 kernel test robot
2025-01-31 17:05 ` Frank van der Linden [this message]
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=CAPTztWb6kO_OkoNz6xHKa-F0VFawCOPc2BO34cRzidnVYCj1ow@mail.gmail.com \
--to=fvdl@google.com \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
--cc=lkp@intel.com \
--cc=oe-kbuild-all@lists.linux.dev \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox