[bug report] vme: Adding Fake VME driver

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

 



Hello Martyn Welch,

The patch 658bcdae9c67: "vme: Adding Fake VME driver" from Jul 7,
2016, leads to the following static checker warning:

	drivers/vme/bridges/vme_fake.c:338 fake_master_set()
	warn: 'spin_lock:&image->lock' is sometimes locked here and sometimes unlocked.

drivers/vme/bridges/vme_fake.c
   255  static int fake_master_set(struct vme_master_resource *image, int enabled,
   256                  unsigned long long vme_base, unsigned long long size,
   257                  u32 aspace, u32 cycle, u32 dwidth)
   258  {
   259          int retval = 0;
   260          unsigned int i;
   261          struct vme_bridge *fake_bridge;
   262          struct fake_driver *bridge;
   263  
   264          fake_bridge = image->parent;
   265  
   266          bridge = fake_bridge->driver_priv;
   267  
   268          /* Verify input data */
   269          if (vme_base & 0xFFFF) {

Unlock?

   270                  pr_err("Invalid VME Window alignment\n");
   271                  retval = -EINVAL;
   272                  goto err_window;
   273          }
   274  
   275          if (size & 0xFFFF) {
   276                  spin_unlock(&image->lock);
   277                  pr_err("Invalid size alignment\n");
   278                  retval = -EINVAL;
   279                  goto err_window;
   280          }
   281  
   282          if ((size == 0) && (enabled != 0)) {

Unlock?

   283                  pr_err("Size must be non-zero for enabled windows\n");
   284                  retval = -EINVAL;
   285                  goto err_window;
   286          }
   287  
   288          /* Setup data width */
   289          switch (dwidth) {
   290          case VME_D8:
   291          case VME_D16:
   292          case VME_D32:
   293                  break;
   294          default:
   295                  spin_unlock(&image->lock);
   296                  pr_err("Invalid data width\n");
   297                  retval = -EINVAL;
   298                  goto err_dwidth;
   299          }
   300  
   301          /* Setup address space */
   302          switch (aspace) {
   303          case VME_A16:
   304          case VME_A24:
   305          case VME_A32:
   306          case VME_A64:
   307          case VME_CRCSR:
   308          case VME_USER1:
   309          case VME_USER2:
   310          case VME_USER3:
   311          case VME_USER4:
   312                  break;
   313          default:
   314                  spin_unlock(&image->lock);
   315                  pr_err("Invalid address space\n");
   316                  retval = -EINVAL;
   317                  goto err_aspace;
   318          }
   319  
   320          spin_lock(&image->lock);
   321  
   322          i = image->number;
   323  
   324          bridge->masters[i].enabled = enabled;
   325          bridge->masters[i].vme_base = vme_base;
   326          bridge->masters[i].size = size;
   327          bridge->masters[i].aspace = aspace;
   328          bridge->masters[i].cycle = cycle;
   329          bridge->masters[i].dwidth = dwidth;
   330  
   331          spin_unlock(&image->lock);
   332  
   333          return 0;
   334  
   335  err_aspace:
   336  err_dwidth:
   337  err_window:
   338          return retval;
   339  
   340  }

regards,
dan carpenter
_______________________________________________
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