]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
i2c: sun6i-p2wi: Prevent potential division by zero
authorAxel Lin <axel.lin@ingics.com>
Wed, 13 Apr 2016 00:54:30 +0000 (08:54 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 28 Nov 2023 16:45:44 +0000 (16:45 +0000)
[ Upstream commit 5ac61d26b8baff5b2e5a9f3dc1ef63297e4b53e7 ]

Make sure we don't OOPS in case clock-frequency is set to 0 in a DT. The
variable set here is later used as a divisor.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/i2c/busses/i2c-sun6i-p2wi.c

index 7c07ce116e38458b00cd93be490cc378f4131f7c..540c33f4e35001a11288e27d68f6910bcdab9e23 100644 (file)
@@ -202,6 +202,11 @@ static int p2wi_probe(struct platform_device *pdev)
                return -EINVAL;
        }
 
+       if (clk_freq == 0) {
+               dev_err(dev, "clock-frequency is set to 0 in DT\n");
+               return -EINVAL;
+       }
+
        if (of_get_child_count(np) > 1) {
                dev_err(dev, "P2WI only supports one slave device\n");
                return -EINVAL;