[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <ae24cd32-1e78-4656-b983-051ed22d86b9@stanley.mountain>
Date: Wed, 19 Feb 2025 16:49:39 +0300
From: Dan Carpenter <dan.carpenter@...aro.org>
To: Jim Qu <Jim.Qu@....com>
Cc: Lukas Wunner <lukas@...ner.de>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>,
Thomas Zimmermann <tzimmermann@...e.de>,
David Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>,
Takashi Iwai <tiwai@...e.de>, dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
Su Hui <suhui@...china.com>
Subject: [PATCH] vgaswitcheroo: Fix error checking in
vga_switcheroo_register_audio_client()
The "id" variable is an enum and in this context it's treated as an
unsigned int so the error handling can never trigger. The
->get_client_id() functions do not currently return any errors but
I imagine that if they did, then the intention was to return
VGA_SWITCHEROO_UNKNOWN_ID on error. Let's check for both negatives
and UNKNOWN_ID so we'll catch it either way.
Reported-by: Su Hui <suhui@...china.com>
Closes: https://lore.kernel.org/all/20231026021056.850680-1-suhui@nfschina.com/
Fixes: 4aaf448fa975 ("vga_switcheroo: set audio client id according to bound GPU id")
Signed-off-by: Dan Carpenter <dan.carpenter@...aro.org>
---
drivers/gpu/vga/vga_switcheroo.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
index 18f2c92beff8..216fb208eb31 100644
--- a/drivers/gpu/vga/vga_switcheroo.c
+++ b/drivers/gpu/vga/vga_switcheroo.c
@@ -375,7 +375,7 @@ int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
mutex_lock(&vgasr_mutex);
if (vgasr_priv.active) {
id = vgasr_priv.handler->get_client_id(vga_dev);
- if (id < 0) {
+ if ((int)id < 0 || id == VGA_SWITCHEROO_UNKNOWN_ID) {
mutex_unlock(&vgasr_mutex);
return -EINVAL;
}
--
2.47.2
Powered by blists - more mailing lists