From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Stefan Roese <sr@denx.de>
Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
Mika Westerberg <mika.westerberg@linux.intel.com>,
Yegor Yefremov <yegorslists@googlemail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Giulio Benetti <giulio.benetti@micronovasrl.com>,
Johan Hovold <johan@kernel.org>
Subject: Re: [PATCH 1/2 v4] serial: mctrl_gpio: Check if GPIO property exisits before requesting it
Date: Tue, 4 Jun 2019 19:45:58 +0300 [thread overview]
Message-ID: <20190604164558.GO9224@smile.fi.intel.com> (raw)
In-Reply-To: <20190603083332.12480-1-sr@denx.de>
On Mon, Jun 03, 2019 at 10:33:31AM +0200, Stefan Roese wrote:
> This patch adds a check for the GPIOs property existence, before the
> GPIO is requested. This fixes an issue seen when the 8250 mctrl_gpio
> support is added (2nd patch in this patch series) on x86 platforms using
> ACPI.
> for (i = 0; i < UART_GPIO_MAX; i++) {
> enum gpiod_flags flags;
> + char *gpio_str;
> +
> + /* Check if GPIO property exists and continue if not */
> + gpio_str = kasprintf(GFP_KERNEL, "%s-gpios",
> + mctrl_gpios_desc[i].name);
> + if (!device_property_present(dev, gpio_str)) {
> + kfree(gpio_str);
> + continue;
> + }
> + kfree(gpio_str);
Can we rather do something like
bool present;
... = kasprintf(...);
// (1)
present = device_property_present(...);
kfree(...);
if (!present)
continue;
?
On top of this, if gpio_str is NULL, we will have KABOOM.
Something like
if (!gpio_str)
continue;
in (1).
>
> if (mctrl_gpios_desc[i].dir_out)
> flags = GPIOD_OUT_LOW;
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2019-06-04 16:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-03 8:33 [PATCH 1/2 v4] serial: mctrl_gpio: Check if GPIO property exisits before requesting it Stefan Roese
2019-06-03 8:33 ` [PATCH 2/2 v4] tty/serial/8250: use mctrl_gpio helpers Stefan Roese
2019-06-04 16:52 ` Andy Shevchenko
2019-06-05 9:35 ` Stefan Roese
2019-06-04 16:45 ` Andy Shevchenko [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=20190604164558.GO9224@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=giulio.benetti@micronovasrl.com \
--cc=gregkh@linuxfoundation.org \
--cc=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=sr@denx.de \
--cc=yegorslists@googlemail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.