[usb:usb-linus 3/10] drivers/media//usb/siano/smsusb.c:447:37: warning: 'in_maxp' may be used uninitialized in this function

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

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-linus
head:   53c7b63f797c96a30c21dd3b781fafaae096a12b
commit: 31e0456de5be379b10fea0fa94a681057114a96e [3/10] media: usb: siano: Fix general protection fault in smsusb
config: mips-allmodconfig (attached as .config)
compiler: mips-linux-gcc (GCC) 8.1.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        git checkout 31e0456de5be379b10fea0fa94a681057114a96e
        # save the attached .config to linux build tree
        GCC_VERSION=8.1.0 make.cross ARCH=mips 

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

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All warnings (new ones prefixed by >>):

   drivers/media//usb/siano/smsusb.c: In function 'smsusb_init_device':
>> drivers/media//usb/siano/smsusb.c:447:37: warning: 'in_maxp' may be used uninitialized in this function [-Wmaybe-uninitialized]
      dev->response_alignment = in_maxp - sizeof(struct sms_msg_hdr);
                                ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +/in_maxp +447 drivers/media//usb/siano/smsusb.c

   396	
   397	static int smsusb_init_device(struct usb_interface *intf, int board_id)
   398	{
   399		struct smsdevice_params_t params;
   400		struct smsusb_device_t *dev;
   401		void *mdev;
   402		int i, rc;
   403		int in_maxp;
   404	
   405		/* create device object */
   406		dev = kzalloc(sizeof(struct smsusb_device_t), GFP_KERNEL);
   407		if (!dev)
   408			return -ENOMEM;
   409	
   410		memset(&params, 0, sizeof(params));
   411		usb_set_intfdata(intf, dev);
   412		dev->udev = interface_to_usbdev(intf);
   413		dev->state = SMSUSB_DISCONNECTED;
   414	
   415		for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) {
   416			struct usb_endpoint_descriptor *desc =
   417					&intf->cur_altsetting->endpoint[i].desc;
   418	
   419			if (desc->bEndpointAddress & USB_DIR_IN) {
   420				dev->in_ep = desc->bEndpointAddress;
   421				in_maxp = usb_endpoint_maxp(desc);
   422			} else {
   423				dev->out_ep = desc->bEndpointAddress;
   424			}
   425		}
   426	
   427		pr_debug("in_ep = %02x, out_ep = %02x\n", dev->in_ep, dev->out_ep);
   428		if (!dev->in_ep || !dev->out_ep) {	/* Missing endpoints? */
   429			smsusb_term_device(intf);
   430			return -ENODEV;
   431		}
   432	
   433		params.device_type = sms_get_board(board_id)->type;
   434	
   435		switch (params.device_type) {
   436		case SMS_STELLAR:
   437			dev->buffer_size = USB1_BUFFER_SIZE;
   438	
   439			params.setmode_handler = smsusb1_setmode;
   440			params.detectmode_handler = smsusb1_detectmode;
   441			break;
   442		case SMS_UNKNOWN_TYPE:
   443			pr_err("Unspecified sms device type!\n");
   444			/* fall-thru */
   445		default:
   446			dev->buffer_size = USB2_BUFFER_SIZE;
 > 447			dev->response_alignment = in_maxp - sizeof(struct sms_msg_hdr);
   448	
   449			params.flags |= SMS_DEVICE_FAMILY2;
   450			break;
   451		}
   452	
   453		params.device = &dev->udev->dev;
   454		params.usb_device = dev->udev;
   455		params.buffer_size = dev->buffer_size;
   456		params.num_buffers = MAX_BUFFERS;
   457		params.sendrequest_handler = smsusb_sendrequest;
   458		params.context = dev;
   459		usb_make_path(dev->udev, params.devpath, sizeof(params.devpath));
   460	
   461		mdev = siano_media_device_register(dev, board_id);
   462	
   463		/* register in smscore */
   464		rc = smscore_register_device(&params, &dev->coredev, 0, mdev);
   465		if (rc < 0) {
   466			pr_err("smscore_register_device(...) failed, rc %d\n", rc);
   467			smsusb_term_device(intf);
   468	#ifdef CONFIG_MEDIA_CONTROLLER_DVB
   469			media_device_unregister(mdev);
   470	#endif
   471			kfree(mdev);
   472			return rc;
   473		}
   474	
   475		smscore_set_board_id(dev->coredev, board_id);
   476	
   477		dev->coredev->is_usb_device = true;
   478	
   479		/* initialize urbs */
   480		for (i = 0; i < MAX_URBS; i++) {
   481			dev->surbs[i].dev = dev;
   482			usb_init_urb(&dev->surbs[i].urb);
   483		}
   484	
   485		pr_debug("smsusb_start_streaming(...).\n");
   486		rc = smsusb_start_streaming(dev);
   487		if (rc < 0) {
   488			pr_err("smsusb_start_streaming(...) failed\n");
   489			smsusb_term_device(intf);
   490			return rc;
   491		}
   492	
   493		dev->state = SMSUSB_ACTIVE;
   494	
   495		rc = smscore_start_device(dev->coredev);
   496		if (rc < 0) {
   497			pr_err("smscore_start_device(...) failed\n");
   498			smsusb_term_device(intf);
   499			return rc;
   500		}
   501	
   502		pr_debug("device 0x%p created\n", dev);
   503	
   504		return rc;
   505	}
   506	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux