mirror of
https://github.com/torvalds/linux.git
synced 2026-09-11 20:13:02 +02:00
watchdog: msc313e: Avoid division by zero
clk_get_rate() could return 0. Avoid a division by zero panic.
Fixes: e9800b7994 ("watchdog: Add Mstar MSC313e WDT driver")
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://patch.msgid.link/20260828161348.13212-3-tzungbi@kernel.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
0fa37512eb
commit
3c73a37f5e
|
|
@ -97,6 +97,7 @@ static int msc313e_wdt_probe(struct platform_device *pdev)
|
|||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct msc313e_wdt_priv *priv;
|
||||
unsigned long rate;
|
||||
|
||||
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
|
||||
if (!priv)
|
||||
|
|
@ -116,7 +117,10 @@ static int msc313e_wdt_probe(struct platform_device *pdev)
|
|||
priv->wdev.ops = &msc313e_wdt_ops,
|
||||
priv->wdev.parent = dev;
|
||||
priv->wdev.min_timeout = MSC313E_WDT_MIN_TIMEOUT;
|
||||
priv->wdev.max_timeout = U32_MAX / clk_get_rate(priv->clk);
|
||||
rate = clk_get_rate(priv->clk);
|
||||
if (!rate)
|
||||
return -EINVAL;
|
||||
priv->wdev.max_timeout = U32_MAX / rate;
|
||||
priv->wdev.timeout = MSC313E_WDT_DEFAULT_TIMEOUT;
|
||||
|
||||
/* If the period is non-zero the WDT is running */
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user