[linux-next:master 1562/1734] drivers/hid/hid-hyperv.c:218:9: sparse: sparse: cast from restricted __le16

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   d25ee88530253138d0b20d43511ca5acbda4e9f7
commit: 602670289b69b2fded3a0b2240c4877e3a015ac6 [1562/1734] fortify: Detect struct member overflows in memcpy() at compile-time
config: i386-allmodconfig (https://download.01.org/0day-ci/archive/20220126/202201261137.2CfyPBXl-lkp@xxxxxxxxx/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.4-dirty
        # https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=602670289b69b2fded3a0b2240c4877e3a015ac6
        git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
        git fetch --no-tags linux-next master
        git checkout 602670289b69b2fded3a0b2240c4877e3a015ac6
        # save the config file to linux build tree
        mkdir build_dir
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 SHELL=/bin/bash drivers/acpi/apei/ drivers/hid/

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


sparse warnings: (new ones prefixed by >>)
   drivers/hid/hid-hyperv.c:202:40: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned int [usertype] report_desc_size @@     got restricted __le16 [usertype] wDescriptorLength @@
   drivers/hid/hid-hyperv.c:202:40: sparse:     expected unsigned int [usertype] report_desc_size
   drivers/hid/hid-hyperv.c:202:40: sparse:     got restricted __le16 [usertype] wDescriptorLength
>> drivers/hid/hid-hyperv.c:218:9: sparse: sparse: cast from restricted __le16
--
   drivers/acpi/apei/erst.c:272:13: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected void *src @@     got void [noderef] __iomem * @@
   drivers/acpi/apei/erst.c:272:13: sparse:     expected void *src
   drivers/acpi/apei/erst.c:272:13: sparse:     got void [noderef] __iomem *
   drivers/acpi/apei/erst.c:275:13: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected void *dst @@     got void [noderef] __iomem * @@
   drivers/acpi/apei/erst.c:275:13: sparse:     expected void *dst
   drivers/acpi/apei/erst.c:275:13: sparse:     got void [noderef] __iomem *
   drivers/acpi/apei/erst.c:277:25: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void volatile [noderef] __iomem *addr @@     got void *src @@
   drivers/acpi/apei/erst.c:277:25: sparse:     expected void volatile [noderef] __iomem *addr
   drivers/acpi/apei/erst.c:277:25: sparse:     got void *src
   drivers/acpi/apei/erst.c:283:17: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void volatile [noderef] __iomem *addr @@     got void *src @@
   drivers/acpi/apei/erst.c:283:17: sparse:     expected void volatile [noderef] __iomem *addr
   drivers/acpi/apei/erst.c:283:17: sparse:     got void *src
   drivers/acpi/apei/erst.c:284:17: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void volatile [noderef] __iomem *addr @@     got void *dst @@
   drivers/acpi/apei/erst.c:284:17: sparse:     expected void volatile [noderef] __iomem *addr
   drivers/acpi/apei/erst.c:284:17: sparse:     got void *dst
>> drivers/acpi/apei/erst.c:792:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const * @@     got void [noderef] __iomem *static [toplevel] vaddr @@
   drivers/acpi/apei/erst.c:792:9: sparse:     expected void const *
   drivers/acpi/apei/erst.c:792:9: sparse:     got void [noderef] __iomem *static [toplevel] vaddr
>> drivers/acpi/apei/erst.c:792:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const * @@     got void [noderef] __iomem *static [toplevel] vaddr @@
   drivers/acpi/apei/erst.c:792:9: sparse:     expected void const *
   drivers/acpi/apei/erst.c:792:9: sparse:     got void [noderef] __iomem *static [toplevel] vaddr
   drivers/acpi/apei/erst.c:792:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void * @@     got void [noderef] __iomem *static [toplevel] vaddr @@
   drivers/acpi/apei/erst.c:792:9: sparse:     expected void *
   drivers/acpi/apei/erst.c:792:9: sparse:     got void [noderef] __iomem *static [toplevel] vaddr
   drivers/acpi/apei/erst.c:793:20: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct cper_record_header *rcd_erange @@     got void [noderef] __iomem *static [toplevel] vaddr @@
   drivers/acpi/apei/erst.c:793:20: sparse:     expected struct cper_record_header *rcd_erange
   drivers/acpi/apei/erst.c:793:20: sparse:     got void [noderef] __iomem *static [toplevel] vaddr
   drivers/acpi/apei/erst.c:830:17: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct cper_record_header *rcd_tmp @@     got void [noderef] __iomem * @@
   drivers/acpi/apei/erst.c:830:17: sparse:     expected struct cper_record_header *rcd_tmp
   drivers/acpi/apei/erst.c:830:17: sparse:     got void [noderef] __iomem *

vim +218 drivers/hid/hid-hyperv.c

b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  180  
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  181  static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  182  				struct synthhid_device_info *device_info)
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  183  {
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  184  	int ret = 0;
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  185  	struct hid_descriptor *desc;
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  186  	struct mousevsc_prt_msg ack;
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  187  
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  188  	input_device->dev_info_status = -ENOMEM;
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  189  
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  190  	input_device->hid_dev_info = device_info->hid_dev_info;
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  191  	desc = &device_info->hid_descriptor;
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  192  	if (desc->bLength == 0)
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  193  		goto cleanup;
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  194  
af13f9ed6f9aa68 Dexuan Cui       2019-11-19  195  	/* The pointer is not NULL when we resume from hibernation */
af13f9ed6f9aa68 Dexuan Cui       2019-11-19  196  	kfree(input_device->hid_desc);
a4a23f6d68ad2c8 Thomas Meyer     2013-06-01  197  	input_device->hid_desc = kmemdup(desc, desc->bLength, GFP_ATOMIC);
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  198  
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  199  	if (!input_device->hid_desc)
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  200  		goto cleanup;
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  201  
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17 @202  	input_device->report_desc_size = desc->desc[0].wDescriptorLength;
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  203  	if (input_device->report_desc_size == 0) {
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  204  		input_device->dev_info_status = -EINVAL;
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  205  		goto cleanup;
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  206  	}
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  207  
af13f9ed6f9aa68 Dexuan Cui       2019-11-19  208  	/* The pointer is not NULL when we resume from hibernation */
af13f9ed6f9aa68 Dexuan Cui       2019-11-19  209  	kfree(input_device->report_desc);
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  210  	input_device->report_desc = kzalloc(input_device->report_desc_size,
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  211  					  GFP_ATOMIC);
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  212  
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  213  	if (!input_device->report_desc) {
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  214  		input_device->dev_info_status = -ENOMEM;
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  215  		goto cleanup;
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  216  	}
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  217  
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17 @218  	memcpy(input_device->report_desc,
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  219  	       ((unsigned char *)desc) + desc->bLength,
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  220  	       desc->desc[0].wDescriptorLength);
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  221  
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  222  	/* Send the ack */
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  223  	memset(&ack, 0, sizeof(struct mousevsc_prt_msg));
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  224  
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  225  	ack.type = PIPE_MESSAGE_DATA;
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  226  	ack.size = sizeof(struct synthhid_device_info_ack);
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  227  
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  228  	ack.ack.header.type = SYNTH_HID_INITIAL_DEVICE_INFO_ACK;
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  229  	ack.ack.header.size = 1;
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  230  	ack.ack.reserved = 0;
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  231  
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  232  	ret = vmbus_sendpacket(input_device->device->channel,
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  233  			&ack,
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  234  			sizeof(struct pipe_prt_msg) - sizeof(unsigned char) +
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  235  			sizeof(struct synthhid_device_info_ack),
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  236  			(unsigned long)&ack,
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  237  			VM_PKT_DATA_INBAND,
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  238  			VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  239  
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  240  	if (!ret)
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  241  		input_device->dev_info_status = 0;
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  242  
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  243  cleanup:
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  244  	complete(&input_device->wait_event);
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  245  
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  246  	return;
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  247  }
b95f5bcb811e390 K. Y. Srinivasan 2011-11-17  248  

:::::: The code at line 218 was first introduced by commit
:::::: b95f5bcb811e3905b5376f87789da8d097fee682 HID: Move the hid-hyperv driver out of staging

:::::: TO: K. Y. Srinivasan <kys@xxxxxxxxxxxxx>
:::::: CC: Jiri Kosina <jkosina@xxxxxxx>

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




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux