lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202507021809.3gclls4s-lkp@intel.com>
Date: Wed, 2 Jul 2025 19:01:07 +0800
From: kernel test robot <lkp@...el.com>
To: Dawid Niedzwiecki <dawidn@...gle.com>,
	Tzung-Bi Shih <tzungbi@...nel.org>,
	Benson Leung <bleung@...omium.org>
Cc: oe-kbuild-all@...ts.linux.dev, chrome-platform@...ts.linux.dev,
	linux-kernel@...r.kernel.org, chromeos-krk-upstreaming@...gle.com,
	Ɓukasz Bartosik <ukaszb@...omium.org>,
	Dawid Niedzwiecki <dawidn@...gle.com>
Subject: Re: [PATCH v2] platform/chrome: Add ChromeOS EC USB driver

Hi Dawid,

kernel test robot noticed the following build warnings:

[auto build test WARNING on chrome-platform/for-next]
[also build test WARNING on chrome-platform/for-firmware-next linus/master v6.16-rc4 next-20250701]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Dawid-Niedzwiecki/platform-chrome-Add-ChromeOS-EC-USB-driver/20250630-202610
base:   https://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux.git for-next
patch link:    https://lore.kernel.org/r/20250630122155.2060589-1-dawidn%40google.com
patch subject: [PATCH v2] platform/chrome: Add ChromeOS EC USB driver
config: i386-randconfig-r122-20250702 (https://download.01.org/0day-ci/archive/20250702/202507021809.3gclls4s-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14+deb12u1) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250702/202507021809.3gclls4s-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@...el.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202507021809.3gclls4s-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
>> drivers/platform/chrome/cros_ec_usb.c:345:50: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned short const [usertype] idProduct @@     got restricted __le16 [usertype] idProduct @@
   drivers/platform/chrome/cros_ec_usb.c:345:50: sparse:     expected unsigned short const [usertype] idProduct
   drivers/platform/chrome/cros_ec_usb.c:345:50: sparse:     got restricted __le16 [usertype] idProduct

vim +345 drivers/platform/chrome/cros_ec_usb.c

   338	
   339	static int cros_ec_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
   340	{
   341		struct usb_device *usb_dev = interface_to_usbdev(intf);
   342		struct usb_endpoint_descriptor *bulk_in, *bulk_out, *int_in;
   343		struct device *if_dev = &intf->dev;
   344		struct cros_ec_device *ec_dev;
 > 345		const u16 idProduct = usb_dev->descriptor.idProduct;
   346		struct cros_ec_usb *ec_usb = cros_ec_usb_get_registered(idProduct);
   347		const bool is_registered = !!ec_usb;
   348		int ret;
   349	
   350		/*
   351		 * Do not register the same EC device twice. The probing is performed every reboot, sysjump,
   352		 * crash etc. Recreating the /dev/cros_X file every time would force all application to
   353		 * reopen the file, which is not a case for other cros_ec_x divers. Instead, keep
   354		 * the cros_ec_device and cros_ec_usb structures constant and replace USB related structures
   355		 * for the same EC that is reprobed.
   356		 *
   357		 * The driver doesn't support handling two devices with the same idProduct, but it will
   358		 * never be a real usecase.
   359		 */
   360		if (!is_registered) {
   361			ec_usb = kzalloc(sizeof(*ec_usb), GFP_KERNEL);
   362			if (!ec_usb)
   363				return -ENOMEM;
   364	
   365			INIT_WORK(&ec_usb->work_ec_evt, usb_evt_handler);
   366	
   367			ec_dev = kzalloc(sizeof(*ec_dev), GFP_KERNEL);
   368			if (!ec_dev) {
   369				ret = -ENOMEM;
   370				goto error;
   371			}
   372	
   373			ec_usb->ec_dev = ec_dev;
   374			mutex_init(&ec_usb->io_mutex);
   375			init_waitqueue_head(&ec_usb->resp_ready_wait);
   376	
   377			ec_dev->priv = ec_usb;
   378			/* EC uses int endpoint to signal events. */
   379			ec_dev->irq = 0;
   380			ec_dev->cmd_xfer = NULL;
   381			ec_dev->pkt_xfer = do_cros_ec_pkt_xfer_usb;
   382			ec_dev->din_size = sizeof(struct ec_host_response) +
   383					   sizeof(struct ec_response_get_protocol_info);
   384			ec_dev->dout_size = sizeof(struct ec_host_request) +
   385					    sizeof(struct ec_params_rwsig_action);
   386		} else {
   387			ec_dev = ec_usb->ec_dev;
   388	
   389			/*
   390			 * We need to allocate dout and din buffers, because cros_ec_register
   391			 * won't be called. These buffers were freed once previous usb device was
   392			 * disconnected. Use buffer sizes from the last query.
   393			 * The EC_HOST_EVENT_INTERFACE_READY event will be triggered at the end
   394			 * of a boot, which calls cros_ec_query_all function, that reallocates
   395			 * buffers.
   396			 */
   397			ec_dev->din = devm_kzalloc(ec_dev->dev, ec_dev->din_size, GFP_KERNEL);
   398			if (!ec_dev->din) {
   399				ret = -ENOMEM;
   400				dev_err(if_dev, "Failed to allocate din buffer\n");
   401				goto error;
   402			}
   403			ec_dev->dout = devm_kzalloc(ec_dev->dev, ec_dev->dout_size, GFP_KERNEL);
   404			if (!ec_dev->dout) {
   405				ret = -ENOMEM;
   406				dev_err(if_dev, "Failed to allocate dout buffer\n");
   407				goto error;
   408			}
   409		}
   410	
   411		ec_dev->dev = if_dev;
   412		ec_dev->phys_name = dev_name(if_dev);
   413		usb_set_intfdata(intf, ec_dev);
   414		/* Allow EC to do remote wake-up - host sends SET_FEATURE(remote wake-up) before suspend. */
   415		device_init_wakeup(&usb_dev->dev, true);
   416	
   417		ec_usb->udev = usb_get_dev(usb_dev);
   418		ec_usb->interface = usb_get_intf(intf);
   419	
   420		/* Use first bulk-in/out endpoints + int-in endpoint */
   421		ret = usb_find_common_endpoints(intf->cur_altsetting, &bulk_in, &bulk_out, &int_in, NULL);
   422		if (ret) {
   423			dev_err(if_dev,
   424				"Could not find bulk-in, bulk-out or int-in endpoint\n");
   425			goto error;
   426		}
   427		/* Bulk endpoints have to be capable of sending headers in one transfer. */
   428		if ((usb_endpoint_maxp(bulk_out) < sizeof(struct ec_host_request)) ||
   429		    (usb_endpoint_maxp(bulk_in) < sizeof(struct ec_host_response)) ||
   430		    (usb_endpoint_maxp(int_in)) < sizeof(struct int_msg)) {
   431			ret = -ENOSPC;
   432			dev_err(if_dev, "Incorrect max packet size\n");
   433			goto error;
   434		}
   435	
   436		ec_usb->bulk_out_pipe = usb_sndbulkpipe(ec_usb->udev, bulk_out->bEndpointAddress);
   437		ec_usb->bulk_in_size = usb_endpoint_maxp(bulk_in);
   438		ec_usb->bulk_in_pipe = usb_rcvbulkpipe(ec_usb->udev, bulk_in->bEndpointAddress);
   439		ec_usb->bulk_in_buffer = kmalloc(ec_usb->bulk_in_size, GFP_KERNEL);
   440		if (!ec_usb->bulk_in_buffer) {
   441			dev_err(if_dev, "Failed to allocate bulk in buffer\n");
   442			ret = -ENOMEM;
   443			goto error;
   444		}
   445	
   446		ec_usb->int_in_size = usb_endpoint_maxp(int_in);
   447		ec_usb->int_in_pipe = usb_rcvintpipe(ec_usb->udev, int_in->bEndpointAddress);
   448		ec_usb->int_in_interval = int_in->bInterval;
   449		ec_usb->int_in_buffer = kmalloc(ec_usb->int_in_size, GFP_KERNEL);
   450		if (!ec_usb->int_in_buffer) {
   451			dev_err(if_dev, "Failed to allocate int in buffer\n");
   452			ret = -ENOMEM;
   453			goto error;
   454		}
   455		ec_usb->int_in_urb = usb_alloc_urb(0, GFP_KERNEL);
   456		if (!ec_usb->int_in_urb) {
   457			dev_err(if_dev, "Failed to allocate int in urb\n");
   458			ret = -ENOMEM;
   459			goto error;
   460		}
   461	
   462		/* Use URB for the int endpoint. */
   463		ret = submit_int_urb(ec_dev);
   464		if (ret) {
   465			dev_err(if_dev, "Failed to sumbit int urb: %d\n", ret);
   466			goto error;
   467		}
   468	
   469		mutex_lock(&ec_usb->io_mutex);
   470		ec_usb->disconnected = false;
   471		mutex_unlock(&ec_usb->io_mutex);
   472	
   473		if (!is_registered) {
   474			ret = cros_ec_register(ec_dev);
   475			if (ret) {
   476				dev_err(if_dev, "Cannot register EC\n");
   477				goto error;
   478			}
   479			ret = cros_ec_usb_register(idProduct, ec_usb);
   480			if (ret) {
   481				cros_ec_unregister(ec_dev);
   482				goto error;
   483			}
   484			ec_usb->registered = true;
   485		}
   486	
   487		/* Handle potential events that haven't been handled before registration */
   488		schedule_work(&ec_usb->work_ec_evt);
   489	
   490		return 0;
   491	
   492	error:
   493		/* Free allocated memory */
   494		cros_ec_usb_delete(ec_usb);
   495	
   496		return ret;
   497	}
   498	

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ