From: Jonathan Cameron <jic23@kernel.org>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Alexandru Ardelean <ardeleanalex@gmail.com>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
linux-iio <linux-iio@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Michael Hennerich <Michael.Hennerich@analog.com>,
Alexandru Tachici <alexandru.tachici@analog.com>
Subject: Re: [PATCH v1 1/1] iio: dac: ad5770r: Put fwnode in error case during ->probe()
Date: Thu, 13 May 2021 18:09:22 +0100 [thread overview]
Message-ID: <20210513180922.44e0a0ad@jic23-huawei> (raw)
In-Reply-To: <CAHp75VfFTnS6+6KwqixTXNsMvC_LWGnY0rv3n9g_-i7HK2eq0w@mail.gmail.com>
On Thu, 13 May 2021 01:00:22 +0300
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
> On Wednesday, May 12, 2021, Alexandru Ardelean <ardeleanalex@gmail.com>
> wrote:
>
> > On Mon, May 10, 2021 at 12:59 PM Andy Shevchenko
> > <andy.shevchenko@gmail.com> wrote:
> > >
> > > device_for_each_child_node() bumps a reference counting of a returned
> > variable.
> > > We have to balance it whenever we return to the caller.
> >
> > This feels like the device_for_each_child_node() [and the of_node
> > variant] iterator[s] need[s] some re-design to account for how easy it
> > is to slip stuff by.
>
>
> I don’t know how you can do it differently if you wish to give a guarantee
> that object doesn’t suddenly disappear while you are iterating over it.
>
> Look at the bus_find_device() and similar APIs, they basically do the
> similar.
>
>
>
> > But that's something quite out of this scope.
> >
> > Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
> >
> >
> Thanks.
>
Applied to the fixes-togreg branch of iio.git and marked for stable.
Thanks,
Joathan
>
> > >
> > > Fixes: cbbb819837f6 ("iio: dac: ad5770r: Add AD5770R support")
> > > Cc: Alexandru Tachici <alexandru.tachici@analog.com>
> > > Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> > > ---
> > > drivers/iio/dac/ad5770r.c | 16 +++++++++++-----
> > > 1 file changed, 11 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/drivers/iio/dac/ad5770r.c b/drivers/iio/dac/ad5770r.c
> > > index 7ab2ccf90863..8107f7bbbe3c 100644
> > > --- a/drivers/iio/dac/ad5770r.c
> > > +++ b/drivers/iio/dac/ad5770r.c
> > > @@ -524,23 +524,29 @@ static int ad5770r_channel_config(struct
> > ad5770r_state *st)
> > > device_for_each_child_node(&st->spi->dev, child) {
> > > ret = fwnode_property_read_u32(child, "num", &num);
> > > if (ret)
> > > - return ret;
> > > - if (num >= AD5770R_MAX_CHANNELS)
> > > - return -EINVAL;
> > > + goto err_child_out;
> > > + if (num >= AD5770R_MAX_CHANNELS) {
> > > + ret = -EINVAL;
> > > + goto err_child_out;
> > > + }
> > >
> > > ret = fwnode_property_read_u32_array(child,
> > >
> > "adi,range-microamp",
> > > tmp, 2);
> > > if (ret)
> > > - return ret;
> > > + goto err_child_out;
> > >
> > > min = tmp[0] / 1000;
> > > max = tmp[1] / 1000;
> > > ret = ad5770r_store_output_range(st, min, max, num);
> > > if (ret)
> > > - return ret;
> > > + goto err_child_out;
> > > }
> > >
> > > + return 0;
> > > +
> > > +err_child_out:
> > > + fwnode_handle_put(child);
> > > return ret;
> > > }
> > >
> > > --
> > > 2.31.1
> > >
> >
>
>
prev parent reply other threads:[~2021-05-13 17:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-10 9:56 [PATCH v1 1/1] iio: dac: ad5770r: Put fwnode in error case during ->probe() Andy Shevchenko
2021-05-12 17:33 ` Alexandru Ardelean
[not found] ` <CAHp75VfFTnS6+6KwqixTXNsMvC_LWGnY0rv3n9g_-i7HK2eq0w@mail.gmail.com>
2021-05-13 17:09 ` 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=20210513180922.44e0a0ad@jic23-huawei \
--to=jic23@kernel.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=Michael.Hennerich@analog.com \
--cc=alexandru.tachici@analog.com \
--cc=andy.shevchenko@gmail.com \
--cc=ardeleanalex@gmail.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--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).