[driver-core:const_driver 12/12] drivers/usb/core/driver.c:80 store_id() error: uninitialized symbol 'usb_dynid'.

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

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git const_driver
head:   be520b87ec28aa3b5c908a859501fb601bd8b322
commit: be520b87ec28aa3b5c908a859501fb601bd8b322 [12/12] USB: move dynamic ids out of usb driver structures
config: i386-randconfig-141-20240613 (https://download.01.org/0day-ci/archive/20240613/202406130740.HIr25kIC-lkp@xxxxxxxxx/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)

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@xxxxxxxxx>
| Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
| Closes: https://lore.kernel.org/r/202406130740.HIr25kIC-lkp@xxxxxxxxx/

smatch warnings:
drivers/usb/core/driver.c:80 store_id() error: uninitialized symbol 'usb_dynid'.

vim +/usb_dynid +80 drivers/usb/core/driver.c

be520b87ec28aa Greg Kroah-Hartman 2024-06-11  70  static int store_id(const struct device_driver *driver, const struct usb_device_id *id)
be520b87ec28aa Greg Kroah-Hartman 2024-06-11  71  {
be520b87ec28aa Greg Kroah-Hartman 2024-06-11  72  	struct usb_dynids *u;
be520b87ec28aa Greg Kroah-Hartman 2024-06-11  73  	struct usb_dynid *usb_dynid;
be520b87ec28aa Greg Kroah-Hartman 2024-06-11  74  
be520b87ec28aa Greg Kroah-Hartman 2024-06-11  75  	u = usb_find_dynids(driver);
be520b87ec28aa Greg Kroah-Hartman 2024-06-11  76  	if (!u) {
be520b87ec28aa Greg Kroah-Hartman 2024-06-11  77  		/* This driver has not stored any ids yet, so make a new entry for it */
be520b87ec28aa Greg Kroah-Hartman 2024-06-11  78  		u = kmalloc(sizeof(*u), GFP_KERNEL);
be520b87ec28aa Greg Kroah-Hartman 2024-06-11  79  		if (!u) {
be520b87ec28aa Greg Kroah-Hartman 2024-06-11 @80  			kfree(usb_dynid);

Delete the kfree()

be520b87ec28aa Greg Kroah-Hartman 2024-06-11  81  			return -ENOMEM;
be520b87ec28aa Greg Kroah-Hartman 2024-06-11  82  		}
be520b87ec28aa Greg Kroah-Hartman 2024-06-11  83  		u->driver = driver;
be520b87ec28aa Greg Kroah-Hartman 2024-06-11  84  		INIT_LIST_HEAD(&u->list);
be520b87ec28aa Greg Kroah-Hartman 2024-06-11  85  		guard(spinlock)(&usb_dynids_lock);
be520b87ec28aa Greg Kroah-Hartman 2024-06-11  86  		list_add_tail(&u->node, &usb_dynids);
be520b87ec28aa Greg Kroah-Hartman 2024-06-11  87  	}
be520b87ec28aa Greg Kroah-Hartman 2024-06-11  88  
be520b87ec28aa Greg Kroah-Hartman 2024-06-11  89  	/* Allocate a new entry and add it to the list of driver ids for this driver */
be520b87ec28aa Greg Kroah-Hartman 2024-06-11  90  	usb_dynid = kmalloc(sizeof(*usb_dynid), GFP_KERNEL);
be520b87ec28aa Greg Kroah-Hartman 2024-06-11  91  	if (!usb_dynid)
be520b87ec28aa Greg Kroah-Hartman 2024-06-11  92  		return -ENOMEM;
be520b87ec28aa Greg Kroah-Hartman 2024-06-11  93  
be520b87ec28aa Greg Kroah-Hartman 2024-06-11  94  	INIT_LIST_HEAD(&usb_dynid->node);
be520b87ec28aa Greg Kroah-Hartman 2024-06-11  95  	memcpy(&usb_dynid->id, id, sizeof(*id));
be520b87ec28aa Greg Kroah-Hartman 2024-06-11  96  	list_add_tail(&usb_dynid->node, &u->list);
be520b87ec28aa Greg Kroah-Hartman 2024-06-11  97  	return 0;
be520b87ec28aa Greg Kroah-Hartman 2024-06-11  98  }

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

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux