lkml.org 
[lkml]   [2023]   [May]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3] i2c: ocores: use devm_ managed clks
On Wed, May 24, 2023 at 09:21:56PM +0200, Christophe JAILLET wrote:
> > + if (ret) {
> > + dev_err(dev,
> > + "clk_prepare_enable failed: %d\n", ret);
> > + return ret;
> > }
> > + rate = clk_get_rate(i2c->clk) / 1000;
>
> Now (because of the devm_clk_get_optional_enabled()), i2c->clk can be NULL,
> so this would deference a NULL pointer.
>

No, it's fine. clk_get_rate() checks for NULL. When a function returns
a mix of error pointers and NULL, like devm_clk_get_optional_enabled(),
then all the functions like this must have NULL checks built it.

regards,
dan carpenter

\
 
 \ /
  Last update: 2023-05-25 11:27    [W:0.106 / U:0.820 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site