Re: [PATCH v3 01/12] gpio: rockchip: avoid division by zero

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 03, 2024 at 03:36:38PM +0800, Ye Zhang wrote:
> If the clk_get_rate return '0', it will happen division by zero.

I don't understand the circumstances when it may happen.

> Fixes: 3bcbd1a85b68 ("gpio/rockchip: support next version gpio controller")

Not sure that this actually fixes anything. See below why I think so.

...

>  	if (bank->gpio_type == GPIO_TYPE_V2 && !IS_ERR(bank->db_clk)) {

Here you explicitly checked that the clock is provided by DT.

...

>  		freq = clk_get_rate(bank->db_clk);

Here you read the frequency which may be 0 in two cases:
1) in DT explicitly set to 0;
2) CCF is disabled.

So, wrong DTs have to be validated / fixed beforehand, correct?

But if the CCF is disabled, the db_clk is NULL. Moreover I don't see
how the db_clk may contain error pointer as you have it filtered out
at _get_bank_data(). So, maybe what you need is to have NULL check
in the conditional and explaining more in the commit message why it
is currently a problematic code?

> +		if (!freq)
> +			return -EINVAL;

-- 
With Best Regards,
Andy Shevchenko






[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux