Skip to content

Commit 0d7ef45

Browse files
Wolfram Sangdavem330
authored andcommitted
ide: palm_bk3710: test clock rate to avoid division by 0
The clk API may return 0 on clk_get_rate, so we should check the result before using it as a divisor. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent eccf432 commit 0d7ef45

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/ide/palm_bk3710.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,8 @@ static int __init palm_bk3710_probe(struct platform_device *pdev)
325325

326326
clk_enable(clk);
327327
rate = clk_get_rate(clk);
328+
if (!rate)
329+
return -EINVAL;
328330

329331
/* NOTE: round *down* to meet minimum timings; we count in clocks */
330332
ideclk_period = 1000000000UL / rate;

0 commit comments

Comments
 (0)