From: Jonathan Cameron <jic23@kernel.org>
To: Tobias Jordan <kernel@cdqe.de>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
Marek Vasut <marek.vasut@gmail.com>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Subject: Re: [PATCH] iio: adc: gyroadc: fix leak of device node iterator
Date: Sat, 26 Sep 2020 15:47:51 +0100 [thread overview]
Message-ID: <20200926154751.0bfd072f@archlinux> (raw)
In-Reply-To: <20200926104515.GA12079@agrajag.zerfleddert.de>
On Sat, 26 Sep 2020 12:45:15 +0200
Tobias Jordan <kernel@cdqe.de> wrote:
> Add missing of_node_put calls for the error paths of the
> for_each_child_of_node loop in rcar_gyroadc_parse_subdevs.
>
> Thought about adding an "goto err_of_node_put" instead, but as the error
> paths are quite divergent, I'm not sure if that wouldn't complicate
> things.
>
> Fixes: 059c53b32329 ("iio: adc: Add Renesas GyroADC driver")
> Signed-off-by: Tobias Jordan <kernel@cdqe.de>
Looks to me like there is one more route out of the
for_each_child_of_node() that this doesn't cover.
if (childmode == RCAR_GYROADC_MODE_SELECT_1_MB88101A)
break;
If you agree, could you add an of_put_node() to that as well.
It's not an error path, but it does break out early.
Probably also want to modify the description of the patch a tiny
bit to match with that changing being in there as well.
Thanks,
Jonathan
> ---
> drivers/iio/adc/rcar-gyroadc.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/iio/adc/rcar-gyroadc.c b/drivers/iio/adc/rcar-gyroadc.c
> index dcaefc108ff6..3746b0276b80 100644
> --- a/drivers/iio/adc/rcar-gyroadc.c
> +++ b/drivers/iio/adc/rcar-gyroadc.c
> @@ -357,6 +357,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev)
> num_channels = ARRAY_SIZE(rcar_gyroadc_iio_channels_3);
> break;
> default:
> + of_node_put(child);
> return -EINVAL;
> }
>
> @@ -374,6 +375,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev)
> dev_err(dev,
> "Failed to get child reg property of ADC \"%pOFn\".\n",
> child);
> + of_node_put(child);
> return ret;
> }
>
> @@ -382,6 +384,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev)
> dev_err(dev,
> "Only %i channels supported with %pOFn, but reg = <%i>.\n",
> num_channels, child, reg);
> + of_node_put(child);
> return -EINVAL;
> }
> }
> @@ -391,6 +394,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev)
> dev_err(dev,
> "Channel %i uses different ADC mode than the rest.\n",
> reg);
> + of_node_put(child);
> return -EINVAL;
> }
>
> @@ -401,6 +405,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev)
> if (IS_ERR(vref)) {
> dev_dbg(dev, "Channel %i 'vref' supply not connected.\n",
> reg);
> + of_node_put(child);
> return PTR_ERR(vref);
> }
>
prev parent reply other threads:[~2020-09-26 14:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-26 10:45 [PATCH] iio: adc: gyroadc: fix leak of device node iterator Tobias Jordan
2020-09-26 14:47 ` Jonathan Cameron [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=20200926154751.0bfd072f@archlinux \
--to=jic23@kernel.org \
--cc=kernel@cdqe.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marek.vasut@gmail.com \
--cc=pmeerw@pmeerw.net \
/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