From: Dan Carpenter <dan.carpenter@oracle.com>
To: Sasha Levin <sashal@kernel.org>
Cc: Nishad Kamdar <nishadkamdar@gmail.com>,
devel@driverdev.osuosl.org, Lars-Peter Clausen <lars@metafoo.de>,
Michael Hennerich <Michael.Hennerich@analog.com>,
linux-iio@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org, outreachy-kernel@googlegroups.com,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
Hartmut Knaack <knaack.h@gmx.de>,
Jonathan Cameron <jic23@kernel.org>
Subject: Re: [PATCH v2] staging: iio: ad7816: Switch to the gpio descriptor interface
Date: Wed, 17 Oct 2018 22:56:32 +0300 [thread overview]
Message-ID: <20181017195632.xqxevygukhat6hkh@mwanda> (raw)
In-Reply-To: <20181017145823.GC135013@sasha-vm>
On Wed, Oct 17, 2018 at 10:58:23AM -0400, Sasha Levin wrote:
> 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?
These are devm_ allocations. They are freed when &spi_dev->dev is
released.
regards,
dan carpenter
next prev parent reply other threads:[~2018-10-17 19:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-17 14:47 Nishad Kamdar
2018-10-17 14:49 ` Lars-Peter Clausen
2018-10-17 14:58 ` Sasha Levin
2018-10-17 19:56 ` Dan Carpenter [this message]
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=20181017195632.xqxevygukhat6hkh@mwanda \
--to=dan.carpenter@oracle.com \
--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 \
--cc=sashal@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
all inboxes | Powered by JetHome®