diff mbox series

[-next] fbdev: savage: Handle err return when savagefb_check_var failed

Message ID 20240416065137.530693-1-caixinchen1@huawei.com (mailing list archive)
State Accepted, archived
Headers show
Series [-next] fbdev: savage: Handle err return when savagefb_check_var failed | expand

Commit Message

Cai Xinchen April 16, 2024, 6:51 a.m. UTC
The commit 04e5eac8f3ab("fbdev: savage: Error out if pixclock equals zero")
checks the value of pixclock to avoid divide-by-zero error. However
the function savagefb_probe doesn't handle the error return of
savagefb_check_var. When pixclock is 0, it will cause divide-by-zero error.

Fixes: 04e5eac8f3ab ("fbdev: savage: Error out if pixclock equals zero")
Signed-off-by: Cai Xinchen <caixinchen1@huawei.com>
Cc: stable@vger.kernel.org
---
 drivers/video/fbdev/savage/savagefb_driver.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Helge Deller April 25, 2024, 10:05 a.m. UTC | #1
On 4/16/24 08:51, Cai Xinchen wrote:
> The commit 04e5eac8f3ab("fbdev: savage: Error out if pixclock equals zero")
> checks the value of pixclock to avoid divide-by-zero error. However
> the function savagefb_probe doesn't handle the error return of
> savagefb_check_var. When pixclock is 0, it will cause divide-by-zero error.
>
> Fixes: 04e5eac8f3ab ("fbdev: savage: Error out if pixclock equals zero")
> Signed-off-by: Cai Xinchen <caixinchen1@huawei.com>
> Cc: stable@vger.kernel.org
> ---
>   drivers/video/fbdev/savage/savagefb_driver.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)

applied.
Thanks!
Helge



>
> diff --git a/drivers/video/fbdev/savage/savagefb_driver.c b/drivers/video/fbdev/savage/savagefb_driver.c
> index ebc9aeffdde7..ac41f8f37589 100644
> --- a/drivers/video/fbdev/savage/savagefb_driver.c
> +++ b/drivers/video/fbdev/savage/savagefb_driver.c
> @@ -2276,7 +2276,10 @@ static int savagefb_probe(struct pci_dev *dev, const struct pci_device_id *id)
>   	if (info->var.xres_virtual > 0x1000)
>   		info->var.xres_virtual = 0x1000;
>   #endif
> -	savagefb_check_var(&info->var, info);
> +	err = savagefb_check_var(&info->var, info);
> +	if (err)
> +		goto failed;
> +
>   	savagefb_set_fix(info);
>
>   	/*
diff mbox series

Patch

diff --git a/drivers/video/fbdev/savage/savagefb_driver.c b/drivers/video/fbdev/savage/savagefb_driver.c
index ebc9aeffdde7..ac41f8f37589 100644
--- a/drivers/video/fbdev/savage/savagefb_driver.c
+++ b/drivers/video/fbdev/savage/savagefb_driver.c
@@ -2276,7 +2276,10 @@  static int savagefb_probe(struct pci_dev *dev, const struct pci_device_id *id)
 	if (info->var.xres_virtual > 0x1000)
 		info->var.xres_virtual = 0x1000;
 #endif
-	savagefb_check_var(&info->var, info);
+	err = savagefb_check_var(&info->var, info);
+	if (err)
+		goto failed;
+
 	savagefb_set_fix(info);
 
 	/*