summaryrefslogtreecommitdiffstats
path: root/kernel/relay.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2018-02-20 14:09:11 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-05-30 07:49:00 +0200
commite163691fa8e8403d1637690c7ef43c0a423deb25 (patch)
tree7d0a7ace4c87ac56b6d264685284b92a09a316a1 /kernel/relay.c
parent7505779c615c6c80b54faf8d21327de5627a4aa2 (diff)
downloadlinux-stable-e163691fa8e8403d1637690c7ef43c0a423deb25.tar.gz
linux-stable-e163691fa8e8403d1637690c7ef43c0a423deb25.tar.bz2
linux-stable-e163691fa8e8403d1637690c7ef43c0a423deb25.zip
md: raid5: avoid string overflow warning
[ Upstream commit 53b8d89ddbdbb0e4625a46d2cdbb6f106c52f801 ] gcc warns about a possible overflow of the kmem_cache string, when adding four characters to a string of the same length: drivers/md/raid5.c: In function 'setup_conf': drivers/md/raid5.c:2207:34: error: '-alt' directive writing 4 bytes into a region of size between 1 and 32 [-Werror=format-overflow=] sprintf(conf->cache_name[1], "%s-alt", conf->cache_name[0]); ^~~~ drivers/md/raid5.c:2207:2: note: 'sprintf' output between 5 and 36 bytes into a destination of size 32 sprintf(conf->cache_name[1], "%s-alt", conf->cache_name[0]); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If I'm counting correctly, we need 11 characters for the fixed part of the string and 18 characters for a 64-bit pointer (when no gendisk is used), so that leaves three characters for conf->level, which should always be sufficient. This makes the code use snprintf() with the correct length, to make the code more robust against changes, and to get the compiler to shut up. In commit f4be6b43f1ac ("md/raid5: ensure we create a unique name for kmem_cache when mddev has no gendisk") from 2010, Neil said that the pointer could be removed "shortly" once devices without gendisk are disallowed. I have no idea if that happened, but if it did, that should probably be changed as well. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Shaohua Li <sh.li@alibaba-inc.com> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'kernel/relay.c')
0 files changed, 0 insertions, 0 deletions