[xilinx-xlnx:xlnx_rebase_v6.1_LTS 572/1065] drivers/gpu/drm/xlnx/xlnx_mixer.c:2218:9: warning: 'strncpy' specified bound 4 equals destination size

kernel test robot lkp at intel.com
Wed Apr 12 10:35:12 PDT 2023


tree:   https://github.com/Xilinx/linux-xlnx xlnx_rebase_v6.1_LTS
head:   e5753363b5e03fc0a3055d5476c6cca93e9ea28b
commit: 02962ad3ef06d0bea1f20e46903cc1e00a9e756e [572/1065] drm: xlnx: mixer: Correct the fourcc string copy
config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20230413/202304130102.nORBEQgd-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 12.1.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://github.com/Xilinx/linux-xlnx/commit/02962ad3ef06d0bea1f20e46903cc1e00a9e756e
        git remote add xilinx-xlnx https://github.com/Xilinx/linux-xlnx
        git fetch --no-tags xilinx-xlnx xlnx_rebase_v6.1_LTS
        git checkout 02962ad3ef06d0bea1f20e46903cc1e00a9e756e
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=alpha olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=alpha SHELL=/bin/bash drivers/gpu/drm/xlnx/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp at intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202304130102.nORBEQgd-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/gpu/drm/xlnx/xlnx_mixer.c: In function 'xlnx_mix_parse_dt_bg_video_fmt':
>> drivers/gpu/drm/xlnx/xlnx_mixer.c:2218:9: warning: 'strncpy' specified bound 4 equals destination size [-Wstringop-truncation]
    2218 |         strncpy((char *)&layer->hw_config.vid_fmt, vformat, 4);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/xlnx/xlnx_mixer.c: In function 'xlnx_mix_of_init_layer':
   drivers/gpu/drm/xlnx/xlnx_mixer.c:2495:9: warning: 'strncpy' specified bound 4 equals destination size [-Wstringop-truncation]
    2495 |         strncpy((char *)&layer->hw_config.vid_fmt, vformat, 4);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +/strncpy +2218 drivers/gpu/drm/xlnx/xlnx_mixer.c

  2196	
  2197	static int xlnx_mix_parse_dt_bg_video_fmt(struct device_node *node,
  2198						  struct xlnx_mix_hw *mixer_hw)
  2199	{
  2200		struct device_node *layer_node;
  2201		struct xlnx_mix_layer_data *layer;
  2202		const char *vformat;
  2203	
  2204		layer_node = of_get_child_by_name(node, "layer_0");
  2205		layer = &mixer_hw->layer_data[XVMIX_MASTER_LAYER_IDX];
  2206	
  2207		/* Set default values */
  2208		layer->hw_config.can_alpha = false;
  2209		layer->hw_config.can_scale = false;
  2210		layer->hw_config.min_width = XVMIX_LAYER_WIDTH_MIN;
  2211		layer->hw_config.min_height = XVMIX_LAYER_HEIGHT_MIN;
  2212	
  2213		if (of_property_read_string(layer_node, "xlnx,vformat",
  2214					    &vformat)) {
  2215			DRM_ERROR("No xlnx,vformat value for layer 0 in dts\n");
  2216			return -EINVAL;
  2217		}
> 2218		strncpy((char *)&layer->hw_config.vid_fmt, vformat, 4);
  2219		layer->hw_config.is_streaming =
  2220			of_property_read_bool(layer_node, "xlnx,layer-streaming");
  2221		if (of_property_read_u32(node, "xlnx,bpc", &mixer_hw->bg_layer_bpc)) {
  2222			DRM_ERROR("Failed to get bits per component (bpc) prop\n");
  2223			return -EINVAL;
  2224		}
  2225		if (of_property_read_u32(layer_node, "xlnx,layer-max-width",
  2226					 &layer->hw_config.max_width)) {
  2227			DRM_ERROR("Failed to get screen width prop\n");
  2228			return -EINVAL;
  2229		} else if (layer->hw_config.max_width > XVMIX_DISP_MAX_WIDTH ||
  2230			   layer->hw_config.max_width < XVMIX_DISP_MIN_WIDTH) {
  2231			DRM_ERROR("Invalid width in dt");
  2232			return -EINVAL;
  2233		}
  2234	
  2235		mixer_hw->max_layer_width = layer->hw_config.max_width;
  2236		if (of_property_read_u32(layer_node, "xlnx,layer-max-height",
  2237					 &layer->hw_config.max_height)) {
  2238			DRM_ERROR("Failed to get screen height prop\n");
  2239			return -EINVAL;
  2240		} else if (layer->hw_config.max_height > XVMIX_DISP_MAX_HEIGHT ||
  2241			   layer->hw_config.max_height < XVMIX_DISP_MIN_HEIGHT) {
  2242			DRM_ERROR("Invalid height in dt");
  2243			return -EINVAL;
  2244		}
  2245	
  2246		mixer_hw->max_layer_height = layer->hw_config.max_height;
  2247		layer->id = XVMIX_LAYER_MASTER;
  2248	
  2249		return 0;
  2250	}
  2251	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests



More information about the linux-arm-kernel mailing list