All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: alsa-devel@alsa-project.org
Subject: Re: [bug report] ASoC: rsnd: add null CLOCKIN support
Date: 10 Jun 2021 13:32:40 +0900	[thread overview]
Message-ID: <871r9atk47.wl-kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <20210610042400.GU10983@kadam>


Hi Dan

Thank you for your feedback

> >  	if (IS_ERR(clk)) {
> >  		dev_err(dev, "create null clk error\n");
> > -		return NULL;
> > +		return PTR_ERR(clk);
> 
> Yes, I think this part is correct.  If an error happens, then it should
> be reported to the user so they can fix it.

Good !

> > @@ -430,9 +430,9 @@ static int rsnd_adg_get_clkin(struct rsnd_priv *priv)
> >  	for (i = 0; i < CLKMAX; i++) {
> >  		clk = devm_clk_get(dev, clk_name[i]);
> >  
> > -		if (IS_ERR(clk))
> > +		if (IS_ERR_OR_NULL(clk))
> >  			clk = rsnd_adg_null_clk_get(priv);
> > -		if (IS_ERR(clk))
> > +		if (IS_ERR_OR_NULL(clk))
> >  			goto err;
> 
> But this is not correct.
> 
> If a function like devm_clk_get() returns NULL, then it's not an error,
> it's something where the user deliberately chose to disable the feature.
> It shouldn't trigger an error message and the rest of the driver should
> be written to accomodate it.
> 
> >  
> >  		adg->clk[i] = clk;
> 
> So we should assign the NULL pointer here and add NULL checks to make
> sure that it doesn't lead to a NULL dereference.

Ah, in this driver, if it got error or NULL clk,
it try to call rsnd_adg_null_clk_get() and use null_clk instead of NULL.
In other words, all adg->clk[i] should not NULL.
If one of them was NULL, it is error for this driver.
If so, my suggested code was OK, I hope.

Thank you for your help !!

Best regards
---
Kuninori Morimoto

      reply	other threads:[~2021-06-10  4:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-09 11:31 [bug report] ASoC: rsnd: add null CLOCKIN support Dan Carpenter
2021-06-09 23:31 ` Kuninori Morimoto
2021-06-10  4:24   ` Dan Carpenter
2021-06-10  4:32     ` Kuninori Morimoto [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871r9atk47.wl-kuninori.morimoto.gx@renesas.com \
    --to=kuninori.morimoto.gx@renesas.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=dan.carpenter@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.