From: Sasha Levin <sashal@kernel.org>
To: Nishad Kamdar <nishadkamdar@gmail.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
Michael Hennerich <Michael.Hennerich@analog.com>,
Jonathan Cameron <jic23@kernel.org>,
Hartmut Knaack <knaack.h@gmx.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-iio@vger.kernel.org, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org, outreachy-kernel@googlegroups.com
Subject: Re: [PATCH v2] staging: iio: ad7816: Switch to the gpio descriptor interface
Date: Wed, 17 Oct 2018 10:58:23 -0400 [thread overview]
Message-ID: <20181017145823.GC135013@sasha-vm> (raw)
In-Reply-To: <20181017144716.GA11485@nishad>
On Wed, Oct 17, 2018 at 08:17:20PM +0530, Nishad Kamdar wrote:
>+ chip->rdwr_pin = devm_gpiod_get(&spi_dev->dev, "rdwr", GPIOD_IN);
>+ if (IS_ERR(chip->rdwr_pin)) {
>+ ret = PTR_ERR(chip->rdwr_pin);
>+ dev_err(&spi_dev->dev, "Failed to request rdwr GPIO: %d\n",
>+ ret);
> return ret;
> }
>- gpio_direction_input(chip->rdwr_pin);
>- ret = devm_gpio_request(&spi_dev->dev, chip->convert_pin,
>- spi_get_device_id(spi_dev)->name);
>- if (ret) {
>- dev_err(&spi_dev->dev, "Fail to request convert gpio PIN %d.\n",
>- chip->convert_pin);
>+ chip->convert_pin = devm_gpiod_get(&spi_dev->dev, "convert", GPIOD_IN);
>+ if (IS_ERR(chip->convert_pin)) {
>+ ret = PTR_ERR(chip->convert_pin);
>+ dev_err(&spi_dev->dev, "Failed to request convert GPIO: %d\n",
>+ ret);
> return ret;
> }
>- gpio_direction_input(chip->convert_pin);
>- ret = devm_gpio_request(&spi_dev->dev, chip->busy_pin,
>- spi_get_device_id(spi_dev)->name);
>- if (ret) {
>- dev_err(&spi_dev->dev, "Fail to request busy gpio PIN %d.\n",
>- chip->busy_pin);
>+ chip->busy_pin = devm_gpiod_get(&spi_dev->dev, "busy", GPIOD_IN);
>+ if (IS_ERR(chip->busy_pin)) {
>+ ret = PTR_ERR(chip->busy_pin);
>+ dev_err(&spi_dev->dev, "Failed to request busy GPIO: %d\n",
>+ ret);
> return ret;
> }
Hm, from what I can tell devm_gpio_request() is allocating some memory,
which makes this a series of 4 allocations.
What happens if the fourth allocation fails? Do we leak the first three?
--
Thanks,
Sasha
next prev parent reply other threads:[~2018-10-17 14:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-17 14:47 [PATCH v2] staging: iio: ad7816: Switch to the gpio descriptor interface Nishad Kamdar
2018-10-17 14:49 ` Lars-Peter Clausen
2018-10-17 14:58 ` Sasha Levin [this message]
2018-10-17 19:56 ` Dan Carpenter
2018-10-18 7:28 ` Phil Reid
2018-10-18 7:40 ` Lars-Peter Clausen
2018-10-21 14:52 ` Jonathan Cameron
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=20181017145823.GC135013@sasha-vm \
--to=sashal@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nishadkamdar@gmail.com \
--cc=outreachy-kernel@googlegroups.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;
as well as URLs for NNTP newsgroup(s).