[bug report] vga_switcheroo: set audio client id according to bound GPU id

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

 



Hello Jim Qu,

The patch 4aaf448fa975: "vga_switcheroo: set audio client id
according to bound GPU id" from Jul 17, 2018, leads to the following
Smatch static checker warning:

	drivers/gpu/vga/vga_switcheroo.c:378 vga_switcheroo_register_audio_client()
	warn: impossible condition '(id < 0) => (0-u32max < 0)'

drivers/gpu/vga/vga_switcheroo.c
   362  int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
   363                          const struct vga_switcheroo_client_ops *ops,
   364                          struct pci_dev *vga_dev)
   365  {
   366          enum vga_switcheroo_client_id id = VGA_SWITCHEROO_UNKNOWN_ID;
   367  
   368          /*
   369           * if vga_switcheroo has enabled, that mean two GPU clients and also
   370           * handler are registered. Get audio client id from bound GPU client
   371           * id directly, otherwise, set it as VGA_SWITCHEROO_UNKNOWN_ID,
   372           * it will set to correct id in later when vga_switcheroo_enable()
   373           * is called.
   374           */
   375          mutex_lock(&vgasr_mutex);
   376          if (vgasr_priv.active) {
   377                  id = vgasr_priv.handler->get_client_id(vga_dev);
   378                  if (id < 0) {

The vga_switcheroo_client_id enum is treated as unsigned in this context.

   379                          mutex_unlock(&vgasr_mutex);
   380                          return -EINVAL;
   381                  }
   382                  /* notify if GPU has been already bound */
   383                  if (ops->gpu_bound)
   384                          ops->gpu_bound(pdev, id);
   385          }
   386          mutex_unlock(&vgasr_mutex);
   387  
   388          return register_client(pdev, ops, id | ID_BIT_AUDIO, vga_dev,
   389                                 false, true);
   390  }

regards,
dan carpenter



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux