On Sun, Apr 16, 2023 at 03:20:40PM +0800, Wang Zhang wrote: > platform_get_irq_optional is a function used to obtain an IRQ > number for a device on a platform. The function returns the IRQ number > associated with the specified device, or a negative error code if it fails. > > The error handling code after the err_clk label should be executed to > release any resources that were allocated for the clock if a negative > error code returned. > > Fix this by assigning irq to ret and changing the direct return to err_clk. The clock is got in ocores_i2c_of_probe(). That function is not always called. So you need to be careful in the error handling that you are not disabling a clock which does not exist.... But i think a better fix is to change ocores_i2c_of_probe() to use devm_clk_get_enabled(), rather than devm_clk_get() so that the driver core will disable to clock if the probe fails, or when the driver is unloaded. Andrew