drivers/gpu/drm/drm_property.c:130:2: warning: 'strncpy' specified bound 32 equals destination size

From: kernel test robot
Date: Sat Jun 12 2021 - 22:53:34 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 43cb5d49a99b3ecd9fef9826899aac948c3048da
commit: 421015713b306e47af95d4d61cdfbd96d462e4cb ARM: 9017/2: Enable KASan for ARM
date: 8 months ago
config: arm-randconfig-r022-20210613 (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=421015713b306e47af95d4d61cdfbd96d462e4cb
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 421015713b306e47af95d4d61cdfbd96d462e4cb
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

drivers/gpu/drm/drm_property.c: In function 'drm_property_create':
>> drivers/gpu/drm/drm_property.c:130:2: warning: 'strncpy' specified bound 32 equals destination size [-Wstringop-truncation]
130 | strncpy(property->name, name, DRM_PROP_NAME_LEN);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
In file included from include/trace/define_trace.h:103,
from include/trace/events/fscache.h:533,
from fs/fscache/internal.h:28,
from fs/fscache/main.c:16:
include/trace/events/fscache.h: In function 'perf_trace_fscache_netfs':
>> include/trace/events/fscache.h:208:7: warning: 'strncpy' specified bound 8 equals destination size [-Wstringop-truncation]
208 | strncpy(__entry->name, netfs->name, 8);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/trace/perf.h:66:4: note: in definition of macro 'DECLARE_EVENT_CLASS'
66 | { assign; } \
| ^~~~~~
include/trace/trace_events.h:79:9: note: in expansion of macro 'PARAMS'
79 | PARAMS(assign), \
| ^~~~~~
include/trace/events/fscache.h:196:1: note: in expansion of macro 'TRACE_EVENT'
196 | TRACE_EVENT(fscache_netfs,
| ^~~~~~~~~~~
include/trace/events/fscache.h:206:6: note: in expansion of macro 'TP_fast_assign'
206 | TP_fast_assign(
| ^~~~~~~~~~~~~~
In file included from include/trace/define_trace.h:102,
from include/trace/events/fscache.h:533,
from fs/fscache/internal.h:28,
from fs/fscache/main.c:16:
include/trace/events/fscache.h: In function 'trace_event_raw_event_fscache_netfs':
>> include/trace/events/fscache.h:208:7: warning: 'strncpy' specified bound 8 equals destination size [-Wstringop-truncation]
208 | strncpy(__entry->name, netfs->name, 8);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/trace/trace_events.h:695:4: note: in definition of macro 'DECLARE_EVENT_CLASS'
695 | { assign; } \
| ^~~~~~
include/trace/trace_events.h:79:9: note: in expansion of macro 'PARAMS'
79 | PARAMS(assign), \
| ^~~~~~
include/trace/events/fscache.h:196:1: note: in expansion of macro 'TRACE_EVENT'
196 | TRACE_EVENT(fscache_netfs,
| ^~~~~~~~~~~
include/trace/events/fscache.h:206:6: note: in expansion of macro 'TP_fast_assign'
206 | TP_fast_assign(
| ^~~~~~~~~~~~~~

Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for PHY_MTK_HDMI
Depends on ARCH_MEDIATEK && OF
Selected by
- DRM_MEDIATEK_HDMI && HAS_IOMEM && DRM_MEDIATEK


vim +/strncpy +130 drivers/gpu/drm/drm_property.c

59e71ee746a37f Daniel Vetter 2016-08-29 80
59e71ee746a37f Daniel Vetter 2016-08-29 81 /**
59e71ee746a37f Daniel Vetter 2016-08-29 82 * drm_property_create - create a new property type
59e71ee746a37f Daniel Vetter 2016-08-29 83 * @dev: drm device
59e71ee746a37f Daniel Vetter 2016-08-29 84 * @flags: flags specifying the property type
59e71ee746a37f Daniel Vetter 2016-08-29 85 * @name: name of the property
59e71ee746a37f Daniel Vetter 2016-08-29 86 * @num_values: number of pre-defined values
59e71ee746a37f Daniel Vetter 2016-08-29 87 *
59e71ee746a37f Daniel Vetter 2016-08-29 88 * This creates a new generic drm property which can then be attached to a drm
6a8a66eda17ea6 Daniel Vetter 2016-11-23 89 * object with drm_object_attach_property(). The returned property object must
6a8a66eda17ea6 Daniel Vetter 2016-11-23 90 * be freed with drm_property_destroy(), which is done automatically when
6a8a66eda17ea6 Daniel Vetter 2016-11-23 91 * calling drm_mode_config_cleanup().
59e71ee746a37f Daniel Vetter 2016-08-29 92 *
59e71ee746a37f Daniel Vetter 2016-08-29 93 * Returns:
59e71ee746a37f Daniel Vetter 2016-08-29 94 * A pointer to the newly created property on success, NULL on failure.
59e71ee746a37f Daniel Vetter 2016-08-29 95 */
51abc97658b954 Ville Syrjälä 2018-03-06 96 struct drm_property *drm_property_create(struct drm_device *dev,
51abc97658b954 Ville Syrjälä 2018-03-06 97 u32 flags, const char *name,
51abc97658b954 Ville Syrjälä 2018-03-06 98 int num_values)
59e71ee746a37f Daniel Vetter 2016-08-29 99 {
59e71ee746a37f Daniel Vetter 2016-08-29 100 struct drm_property *property = NULL;
59e71ee746a37f Daniel Vetter 2016-08-29 101 int ret;
59e71ee746a37f Daniel Vetter 2016-08-29 102
100bc0d9963b50 Ville Syrjälä 2018-03-06 103 if (WARN_ON(!drm_property_flags_valid(flags)))
100bc0d9963b50 Ville Syrjälä 2018-03-06 104 return NULL;
100bc0d9963b50 Ville Syrjälä 2018-03-06 105
5ebbb5b4d424e0 Ville Syrjälä 2018-03-02 106 if (WARN_ON(strlen(name) >= DRM_PROP_NAME_LEN))
5ebbb5b4d424e0 Ville Syrjälä 2018-03-02 107 return NULL;
5ebbb5b4d424e0 Ville Syrjälä 2018-03-02 108
59e71ee746a37f Daniel Vetter 2016-08-29 109 property = kzalloc(sizeof(struct drm_property), GFP_KERNEL);
59e71ee746a37f Daniel Vetter 2016-08-29 110 if (!property)
59e71ee746a37f Daniel Vetter 2016-08-29 111 return NULL;
59e71ee746a37f Daniel Vetter 2016-08-29 112
59e71ee746a37f Daniel Vetter 2016-08-29 113 property->dev = dev;
59e71ee746a37f Daniel Vetter 2016-08-29 114
59e71ee746a37f Daniel Vetter 2016-08-29 115 if (num_values) {
59e71ee746a37f Daniel Vetter 2016-08-29 116 property->values = kcalloc(num_values, sizeof(uint64_t),
59e71ee746a37f Daniel Vetter 2016-08-29 117 GFP_KERNEL);
59e71ee746a37f Daniel Vetter 2016-08-29 118 if (!property->values)
59e71ee746a37f Daniel Vetter 2016-08-29 119 goto fail;
59e71ee746a37f Daniel Vetter 2016-08-29 120 }
59e71ee746a37f Daniel Vetter 2016-08-29 121
2135ea7aafa26b Thierry Reding 2017-02-28 122 ret = drm_mode_object_add(dev, &property->base, DRM_MODE_OBJECT_PROPERTY);
59e71ee746a37f Daniel Vetter 2016-08-29 123 if (ret)
59e71ee746a37f Daniel Vetter 2016-08-29 124 goto fail;
59e71ee746a37f Daniel Vetter 2016-08-29 125
59e71ee746a37f Daniel Vetter 2016-08-29 126 property->flags = flags;
59e71ee746a37f Daniel Vetter 2016-08-29 127 property->num_values = num_values;
59e71ee746a37f Daniel Vetter 2016-08-29 128 INIT_LIST_HEAD(&property->enum_list);
59e71ee746a37f Daniel Vetter 2016-08-29 129
59e71ee746a37f Daniel Vetter 2016-08-29 @130 strncpy(property->name, name, DRM_PROP_NAME_LEN);
59e71ee746a37f Daniel Vetter 2016-08-29 131 property->name[DRM_PROP_NAME_LEN-1] = '\0';
59e71ee746a37f Daniel Vetter 2016-08-29 132
59e71ee746a37f Daniel Vetter 2016-08-29 133 list_add_tail(&property->head, &dev->mode_config.property_list);
59e71ee746a37f Daniel Vetter 2016-08-29 134
59e71ee746a37f Daniel Vetter 2016-08-29 135 return property;
59e71ee746a37f Daniel Vetter 2016-08-29 136 fail:
59e71ee746a37f Daniel Vetter 2016-08-29 137 kfree(property->values);
59e71ee746a37f Daniel Vetter 2016-08-29 138 kfree(property);
59e71ee746a37f Daniel Vetter 2016-08-29 139 return NULL;
59e71ee746a37f Daniel Vetter 2016-08-29 140 }
59e71ee746a37f Daniel Vetter 2016-08-29 141 EXPORT_SYMBOL(drm_property_create);
59e71ee746a37f Daniel Vetter 2016-08-29 142

:::::: The code at line 130 was first introduced by commit
:::::: 59e71ee746a37fe077b73cecf189de1d27efd6eb drm: Extract drm_property.[hc]

:::::: TO: Daniel Vetter <daniel.vetter@xxxxxxxx>
:::::: CC: Daniel Vetter <daniel.vetter@xxxxxxxx>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip