[bug report] vga_switcheroo: set audio client id according to bound GPU id
Dan Carpenter
error27 at gmail.com
Sat Mar 25 09:04:48 UTC 2023
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: unsigned 'id' is never less than zero.
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) {
enum types are slightly up to the compiler in C. In this context it is
an unsigned int. On the other hand vgasr_priv.handler->get_client_id()
never returns negative values.
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
More information about the dri-devel
mailing list