From: Dan Carpenter <dan.carpenter@linaro.org>
To: Charles Keepax <ckeepax@opensource.cirrus.com>
Cc: linus.walleij@linaro.org, brgl@bgdev.pl,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
patches@opensource.cirrus.com
Subject: Re: [PATCH] gpio: swnode: Don't use __free() on result of swnode_get_gpio_device()
Date: Tue, 5 Mar 2024 17:14:33 +0300 [thread overview]
Message-ID: <cbb40800-d01a-4e3b-bf36-6cfcb85b2796@moroto.mountain> (raw)
In-Reply-To: <20240304160320.1054811-1-ckeepax@opensource.cirrus.com>
On Mon, Mar 04, 2024 at 04:03:20PM +0000, Charles Keepax wrote:
> swnode_get_gpio_device() can return an error pointer, however
> gpio_device_put() is not able to accept error values. Thus using
> __free() will result in dereferencing an invalid pointer.
>
No, this code works as-is. The gpio_device_put() won't be called
directly, it will be called by a wrapper that checks for error pointers.
The __free() stuff is defined like this:
include/linux/gpio/driver.h
655 DEFINE_FREE(gpio_device_put, struct gpio_device *,
656 if (!IS_ERR_OR_NULL(_T)) gpio_device_put(_T))
So it handles error pointers correctly.
regards,
dan carpenter
prev parent reply other threads:[~2024-03-05 14:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-04 16:03 [PATCH] gpio: swnode: Don't use __free() on result of swnode_get_gpio_device() Charles Keepax
2024-03-04 16:34 ` Bartosz Golaszewski
2024-03-04 17:08 ` Charles Keepax
2024-03-05 14:14 ` Dan Carpenter [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=cbb40800-d01a-4e3b-bf36-6cfcb85b2796@moroto.mountain \
--to=dan.carpenter@linaro.org \
--cc=brgl@bgdev.pl \
--cc=ckeepax@opensource.cirrus.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
/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