* [PATCH v2] vga_switcheroo: Fix impossible judgment condition
@ 2023-10-26 9:18 ` Su Hui
0 siblings, 0 replies; 4+ messages in thread
From: Su Hui @ 2023-10-26 9:18 UTC (permalink / raw)
To: dan.carpenter, lukas, maarten.lankhorst, mripard, tzimmermann,
airlied, daniel
Cc: Su Hui, tiwai, Jim.Qu, dri-devel, linux-kernel, kernel-janitors
'id' is enum type like unsigned int, so it will never be less than zero.
It's better to check VGA_SWITCHEROO_UNKNOWN_ID too.
Fixes: 4aaf448fa975 ("vga_switcheroo: set audio client id according to bound GPU id")
Signed-off-by: Su Hui <suhui@nfschina.com>
---
v2:
- add check of VGA_SWITCHEROO_UNKNOWN_ID(Dan's suggestion).
By the way, all functions of 'get_client_id' will never return error code
or VGA_SWITCHEROO_UNKNOWN_ID,should we remove this check or keep it for
future.
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 365e6ddbe90f..cf530094f929 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.30.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2] vga_switcheroo: Fix impossible judgment condition
@ 2023-10-26 9:18 ` Su Hui
0 siblings, 0 replies; 4+ messages in thread
From: Su Hui @ 2023-10-26 9:18 UTC (permalink / raw)
To: dan.carpenter, lukas, maarten.lankhorst, mripard, tzimmermann,
airlied, daniel
Cc: Su Hui, kernel-janitors, linux-kernel, dri-devel, Jim.Qu
'id' is enum type like unsigned int, so it will never be less than zero.
It's better to check VGA_SWITCHEROO_UNKNOWN_ID too.
Fixes: 4aaf448fa975 ("vga_switcheroo: set audio client id according to bound GPU id")
Signed-off-by: Su Hui <suhui@nfschina.com>
---
v2:
- add check of VGA_SWITCHEROO_UNKNOWN_ID(Dan's suggestion).
By the way, all functions of 'get_client_id' will never return error code
or VGA_SWITCHEROO_UNKNOWN_ID,should we remove this check or keep it for
future.
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 365e6ddbe90f..cf530094f929 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.30.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] vga_switcheroo: Fix impossible judgment condition
2023-10-26 9:18 ` Su Hui
@ 2023-10-26 9:30 ` Dan Carpenter
-1 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2023-10-26 9:30 UTC (permalink / raw)
To: Su Hui
Cc: lukas, maarten.lankhorst, mripard, tzimmermann, airlied, daniel,
tiwai, Jim.Qu, dri-devel, linux-kernel, kernel-janitors
On Thu, Oct 26, 2023 at 05:18:04PM +0800, Su Hui wrote:
> 'id' is enum type like unsigned int, so it will never be less than zero.
> It's better to check VGA_SWITCHEROO_UNKNOWN_ID too.
>
> Fixes: 4aaf448fa975 ("vga_switcheroo: set audio client id according to bound GPU id")
> Signed-off-by: Su Hui <suhui@nfschina.com>
> ---
> v2:
> - add check of VGA_SWITCHEROO_UNKNOWN_ID(Dan's suggestion).
>
> By the way, all functions of 'get_client_id' will never return error code
> or VGA_SWITCHEROO_UNKNOWN_ID,should we remove this check or keep it for
> future.
>
Thanks!
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] vga_switcheroo: Fix impossible judgment condition
@ 2023-10-26 9:30 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2023-10-26 9:30 UTC (permalink / raw)
To: Su Hui
Cc: tzimmermann, kernel-janitors, linux-kernel, mripard, Jim.Qu, dri-devel
On Thu, Oct 26, 2023 at 05:18:04PM +0800, Su Hui wrote:
> 'id' is enum type like unsigned int, so it will never be less than zero.
> It's better to check VGA_SWITCHEROO_UNKNOWN_ID too.
>
> Fixes: 4aaf448fa975 ("vga_switcheroo: set audio client id according to bound GPU id")
> Signed-off-by: Su Hui <suhui@nfschina.com>
> ---
> v2:
> - add check of VGA_SWITCHEROO_UNKNOWN_ID(Dan's suggestion).
>
> By the way, all functions of 'get_client_id' will never return error code
> or VGA_SWITCHEROO_UNKNOWN_ID,should we remove this check or keep it for
> future.
>
Thanks!
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-10-26 9:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-26 9:18 [PATCH v2] vga_switcheroo: Fix impossible judgment condition Su Hui
2023-10-26 9:18 ` Su Hui
2023-10-26 9:30 ` Dan Carpenter
2023-10-26 9:30 ` Dan Carpenter
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.