linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Axel Lin <axel.lin@ingics.com>
To: "cy_huang(黃啟原)" <cy_huang@richtek.com>
Cc: "broonie@kernel.org" <broonie@kernel.org>,
	"lgirdwood@gmail.com" <lgirdwood@gmail.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] regulator: rt4801: Fix NULL pointer dereference if priv->enable_gpios is NULL
Date: Thu, 3 Jun 2021 19:20:57 +0800	[thread overview]
Message-ID: <CAFRkauCQ-BTbad8dgDgduDA8QCFTxbocmLxU+sKErUB8WO4bzQ@mail.gmail.com> (raw)
In-Reply-To: <1622716791.1034.13.camel@richtek.com>

cy_huang(黃啟原) <cy_huang@richtek.com> 於 2021年6月3日 週四 下午6:39寫道:
>
> Hi, Axel:
>
> Which case will cause this error? I'm not really sure.
> But if devm_gpiod_get_array_optional will return null, then it must be check
> earlier in probe function
>
>         priv->enable_gpios = devm_gpiod_get_array_optional(&i2c->dev, "enable",
> GPIOD_OUT_HIGH);
> -       if (IS_ERR(priv->enable_gpios)) {+       if (IS_ERR_OR_NULL(priv->enable_gpios)) {
>
> If so, this change will be more reasonable.
> Cause in binding document, I already write the min item must be '1'.

Documentation/devicetree/bindings/regulator/richtek,rt4801-regulator.yaml
  enable-gpios:
    description: GPIOs to use to enable DSVP/DSVN regulator.
      The first one is ENP to enable DSVP, and second one is ENM to enable DSVN.
      Number of GPIO in the array list could be 1 or 2.
      If only one gpio is specified, only one gpio used to control ENP/ENM.
      Else both are spefied, DSVP/DSVN could be controlled individually.
      Othersie, this property not specified. treat both as always-on regulator.
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this  imply it's optional.

If it's cannot be optional, you should use devm_gpiod_get_array() instead.

Regards,
Axel

  reply	other threads:[~2021-06-03 11:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-03  9:49 [PATCH] regulator: rt4801: Fix NULL pointer dereference if priv->enable_gpios is NULL Axel Lin
2021-06-03 10:39 ` cy_huang(黃啟原)
2021-06-03 11:20   ` Axel Lin [this message]
2021-06-03 12:25     ` cy_huang(黃啟原)
2021-06-03 18:41 ` Mark Brown

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=CAFRkauCQ-BTbad8dgDgduDA8QCFTxbocmLxU+sKErUB8WO4bzQ@mail.gmail.com \
    --to=axel.lin@ingics.com \
    --cc=broonie@kernel.org \
    --cc=cy_huang@richtek.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).